values.where(gt(10)) // all values that are greater than 10
range(10).each(add(1)).eq(count(10)) // [0, 10) -> increment each -> [1, 10]
objects.each(index('a')) // get item["a"]
arrays.each(index(0)) // get the first column of a 2d array
arrays.each(index(0, 0)) // get the the bottom-left edge of a 3d array
dicts.each(item('a')) // get values for the key "a" from native
objects or dictionaries
elements.where(index('children', 'length')).to(gt(10))) // get all
elements that have more than 10 children. This requires an extention
to Function.prototype that is now available in boost.js. "to"
performs composition with the arguments in reverse order so it can
resemble a pipe-line (much like iteration pipe-lines):
values.each(f.to(g)) == values.eachIter(f).each(g) // function composition
mul(2)("a") == "aa" // now supporting stringMul from Steve's experiment
add(2)(2) == 4 // curry
add(2, 2) == 4 // normal
add(1, 1, 1) == 3 // variadic
I know: there are three base cases, combining two idioms. It's a bit
more complicated to learn, but the code is generalized so it will work
for all binary operators without fail, and it'll work well for the
most common use cases. Also, I reserve the right to change my mind
until I've tagged 0.1 at the end of this month and hear that people
(other than myself) are using Chiron.
Also, all binary and unary operators have common mechanisms now
(operator1 and operator2) that permit them to perform their curry and
look for polymorphic overrides in Chiron types. Unfortunately, this
didn't make the library any smaller, but it will be more consistent
and less likely to be buggy.
I'm interested in hearing reactions. I anticipate debate.
Kris.