Skip to content

Instantly share code, notes, and snippets.

@maddievision
Created March 26, 2013 05:40
Show Gist options
  • Save maddievision/5243396 to your computer and use it in GitHub Desktop.
Save maddievision/5243396 to your computer and use it in GitHub Desktop.
more fantasy land
LISP
(defun lazy-mapcan (fun lst)
(labels ((f (lst-cur)
(if (lazy-null lst-cur)
(force (lazy-mapcan fun (lazy-cdr lst)))
(cons (lazy-car lst-cur) (lazy (f (lazy-cdr lst-cur)))))))
(lazy (unless (lazy-null lst)
(f (funcall fun (lazy-car lst)))))))
1 (semi-compact)
defun
lazy-mapcan
fun lst
labels
f
lst-cur
if
lazy-null lst-cur
force (lazy-mapcan fun (lazy-cdr lst))
lazy
unless (lazy-null lst)
f (funcall fun (lazy-car lst))
2 (expanded)
defun
lazy-mapcan
fun lst
labels
f
lst-cur
if
lazy-null lst-cur
force
lazy-mapcan
fun
lazy-cdr lst
lazy
unless
lazy-null lst
f
funcall
fun
lazy-car lst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment