Hi all,<div><br></div><div>I&#39;m new to scheme and I was trying to better understand the &#39;call-with-current-continuation&#39; feature. I was surprised of the imperative style used in the examples with set!. I&#39;ve actually written a purely functional example and I was willing to have your opinion about this style of programming.</div>
<div><br></div><div>---------------</div><div>(define (parcour test? lst return)</div><div><div>  (define f-return (foldl</div><div>     (lambda (element c-return)</div><div>       (call/cc (lambda (here) </div><div>                  (if (test? element) </div>
<div>                      (c-return (cons element here)) </div><div>                      c-return))))</div><div>     return lst))</div><div>  (f-return &#39;end))</div><div><br></div><div>(define (add-odd-number lst)</div>
<div>  (define (iter-rec p accu)</div><div>    (match p</div><div>      [&#39;end accu]</div><div>      [(cons v k-new) (let ([p-new (call/cc k-new)])</div><div>                        (iter-rec p-new (+ accu v)))]))</div>
<div>  (define p0 (call/cc (lambda(k) (parcour odd? lst k))))</div><div>  (iter-rec p0 0)</div><div>)</div><div><br></div><div>(add-odd-number &#39;(0 1 2 3 4 5 6 7 8 9 13 27 98 101))</div><div>-------------------</div><div>
<br></div><div>Othewise I have a question:</div><div>Python feature the &#39;yield&#39; keyword that allows to create very easily coroutines and use them in a for loop. I understood that scheme allows this kind of programming with call/cc but it seems to me that it does require a significant amout of boiler-plate code and I was wondering if there is a short direct syntax similar to the &#39;yield&#39; of Python.</div>
<div><br></div><div>Best regards,</div><div>Francesco</div></div>