Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdEnumerator #25

Open
35 of 43 tasks
sancarn opened this issue Mar 24, 2021 · 0 comments
Open
35 of 43 tasks

stdEnumerator #25

sancarn opened this issue Mar 24, 2021 · 0 comments
Labels
enhancement New feature or request lib-stdEnumerator megathread Many bundled feature requests for an individual class

Comments

@sancarn
Copy link
Owner

sancarn commented Mar 24, 2021

GENERAL FEATURES

  • Collection/Dictionary Key preservation
  • Better IEnumVARIANT handling

CONSTRUCTORS

INSTANCE PROPERTIES

  • Get/Let/Set item
  • Get length

INSTANCE METHODS

Many methods were inspired by those in Ruby's Enumerable: https://ruby-doc.org/core-2.7.2/Enumerable.html

  • asCollection()
  • asArray(iType as vbVarType)
  • asDictionary()
  • Sort()
  • Reverse()
  • ForEach
  • Map
  • Unique
  • Filter
  • Concat
  • Join
  • indexOf
  • lastIndexOf
  • includes
  • reduce
  • countBy
  • groupBy
  • max(cb)
  • min(cb)
  • sum(cb)
  • Flatten
  • cycle
  • findFirst
  • checkAll
  • checkAny
  • checkNone
  • checkOnlyOne
  • forEachConsecutive
    • [1,2,3,4,5].each_cons(2,cb) ==> [[1,2],[2,3],[3,4],[4,5]]
  • forEachSlice
    • [1,2,3,4,5].each_slice(2,cb) ==> [[1,2],[3,4],[5]]
  • partition
    • [1,2,3,4,5,6].partition(a=>a%2=0) ==> [[2,4,6],[1,3,5]]
  • zip
    • [1,2,3].zip([4,5,6]) ==> [[1,4],[2,5],[3,6]]
    • [1,2,3].zip([1,2]) ==> [[1,1],[2,2],[3,null]]
  • forEachFixedLengthCombination
    • [1,2,3,4,5].eachFixedLengthCombination(cb, 3) ==> [[1,2,3],[1,2,4],[1,2,5], ... [3,4,5]]

WHAT WE WON'T DO:

  • with_index - this can't be easily done, so instead implement methods like `forEach(cb,withIndex?=false)
  • with_object - this can be done with cb.Bind()

Things we can't do (yet)

  • take <-- can't do this unless we implement IEnumVARIANT and call Next() method
  • tally <-- Would like to do this but can't until we have stdDictionary ["a","b","c","b","a","b"].tally ==> {a:2, b:3, c:1}
  • to_dict <-- requires stdDictioanry ["a",1,"b",2].to_dict ==> {a:1, b:2}
  • groupBy <-- requires stdDictionary - this has been implemented currently using Scripting.Dictionary
@sancarn sancarn added enhancement New feature or request megathread Many bundled feature requests for an individual class labels Mar 24, 2021
@sancarn sancarn added this to Roadmap May 27, 2024
@sancarn sancarn moved this to READY in Roadmap May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lib-stdEnumerator megathread Many bundled feature requests for an individual class
Projects
Status: READY
Development

No branches or pull requests

1 participant