zlacker

[return to "Rama on Clojure's terms, and the magic of continuation-passing style"]
1. robert+uo1[view] [source] 2024-10-14 16:19:19
>>nathan+(OP)
This article is written for people who know Clojure, or at least the examples are. It might be nice to see the examples written in a non-LISP as well.

E.g.

  (?<-
    (ops/explode [1 2 3 4] :> *v)
      (println "Val:" *v))
Is (I believe) the equivalent of Python's

  for element in [1, 2, 3, 4]:
    print(element)
◧◩
2. nathan+uI1[view] [source] 2024-10-14 18:13:21
>>robert+uo1
That Python code has the same effect, but the equivalent Python in CPS would be:

  def explode(args, cont):
    for e in args:
       cont(e)
  
  (explode [1, 2, 3, 4], print)
[go to top]