Re:Ask HN: How to compose two mapping functions into a third?
by paulgb on Wednesday December 10, 2008 @10:45PM
(#393908)
You could use lazy lists like (I think) Haskell uses:
Because the lists are lazy, the maps will only be applied as each value is actually needed, like you described.
[ Parent
| on HN ]
Re:Ask HN: How to compose two mapping functions into a third?
by gruseom on Thursday December 11, 2008 @01:55AM
(#394066)
Yes, I'm beginning to think the simple solution to this boils down to some flavor of coroutines/continuations/laziness - basically, the stuff that Scheme has that CL does not.
The reason I find this interesting is that it's the first real problem I've run into where CL didn't have an easy way to do what I want. There are workarounds, of course. But it's interesting to run into a production (as opposed to academic) problem where the elegant solution isn't simply available.
Re:Ask HN: How to compose two mapping functions into a third?
by simonb on Thursday December 11, 2008 @02:43AM
(#394108)
Have you tried (semi-standard) SERIES?
"A series is a data structure much like a sequence, with similar kinds of operations. The difference is that in many situations, operations on series may be composed functionally and yet execute iteratively, without the need to construct intermediate series values explicitly. In this manner, series provide both the clarity of a functional programming style and the efficiency of an iterative programming style."
Re:Ask HN: How to compose two mapping functions into a third?
by gruseom on Saturday December 13, 2008 @11:31PM
(#397218)
No, I haven't tried it. In fact, I didn't know it was available open-source. Do you use it? If so, do you like it?
Re:Ask HN: How to compose two mapping functions into a third?
by silverlake on Thursday December 11, 2008 @11:22AM
(#394406)
You can implement the local transformations for short cut deforestation with CL macros. Then you can easily reuse the technique everywhere. Look up Andy Gill's paper from 1993.