Name: Anonymous 2015-04-26 21:07
I've never really understood the Y combinator.
#lang racket
(require racket/control)
(define (product-delim xs)
(define (go ys acc)
(cond
((null? ys) acc)
(#t (reset (begin
(display (car ys))
(newline)
(go (cdr ys)
(shift k
(if (eq? (car ys) 0) ; The most salient part
0
(k (* (car ys) acc))))))))))
(go xs 1))
k
is called only in the branch where the car of the list is non-zero, right? But when I run (product-delim '(2 4 0 1 2 3))
, I get the output2
4
0
0