Yes, I actually get paid to write code like this

Sep 24, 2005 20:23

I wrote the following code for work the other day. And I wrote it because it actually made it simpler to write the program I was writing:

(define (contextual-fold-right contextual-kons
contextual-knil
advance-context
initial-context
. lists)
(if (any null? lists)
(contextual-knil initial-context)
(apply contextual-kons
`(,initial-context
,@(map car lists)
,(apply contextual-fold-right
`(,contextual-kons
,contextual-knil
,advance-context
,(apply advance-context
(cons initial-context
(map car lists)))
,@(map cdr lists)))))))

This is probably pretty opaque for people who don't know what fold-right is.
Previous post Next post
Up