Hi,
I remember reading a presentation which said that Nim could replace s.add("a").add("b") to s.add("ab") at compile time. I'm just curious, if I have a code like this:
echo len(mySeq) # that is 1.000.000 int elements, mostly random
echo map(mySeq, x=>x+1).filter(x mod 94117 == 3) # this prints only 10 elements
Then my question is: could we create a rule to replace filter(map(...)) in this case to filter(mapReturingAnIteratorInsteadOfStoringAllTheResults(...))? I would like to avoid storing the intermediate values. In this case it is clear that there is no need to allocate 1MM ints (again).
This is one means of joining terms:
template doJoin(a,b: expr): expr =
proc `a b`() = echo "Hello"
doJoin(ebony, ivory)
ebonyivory()