40ants / lisp-project-of-the-day

Here I'll post notes about Quicklisp projects. Also I publish them on Twitter account svetlyak40wt.
http://40ants.com/lisp-project-of-the-day/
BSD 2-Clause "Simplified" License
51 stars 6 forks source link

cl-stream #23

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

cl-stream

https://40ants.com/lisp-project-of-the-day/2020/08/0149-cl-stream.html

sirherrbatka commented 3 years ago

I think that it is very useful tool for certain types of use cases, especially when combined with aggregation functions and stuff like that. For instance consider this example with group-by https://github.com/sirherrbatka/cl-data-structures/blob/52914da9448208a66a06e1da7a874ddb9e2969d1/src/dicts/hamt/range-test.lisp#L49 or this little snippet

(~> *input*
     (cl-ds.alg:without #'null)
     cl-ds.alg:array-elementwise
     (cl-ds.math:average :sum 0.0))

Stream functions allow me to write more concise code (and less of it). They are great for pseudo-SQL kind of stuff.

svetlyak40wt commented 3 years ago

It is not that kind of streams. You are talking about arrow functions:

https://40ants.com/lisp-project-of-the-day/2020/04/0046-arrows.html

sirherrbatka commented 3 years ago

Arrow macro is cool. But I am talking about functions in the cl-ds package. Without, array-elementwise, group-by and so one work by creating lazily evaluated streams.