Questions tagged [callcc]

call-with-current-continuation (abbreviated as call/cc) is a control operator in functional programming

The function call-with-current-continuation, commonly abbreviated call/cc, is a control operator in functional programming that originated in the Scheme programming language. It takes a function f as its only argument and applies f to the current continuation (a first-class value represented as a function).

85 questions
0
votes
2 answers

Task execution pause/resume in Rust async? (tokio)

How can I pause an async task in Rust? Swift has withCheckedContinuation(function:_:) that pauses current task and returns saved context that can be resumed at desired time. (a.k.a. call/cc) tokio has tokio::task::yield_now, but it can resume…
eonil
  • 83,476
  • 81
  • 317
  • 516
0
votes
1 answer

Clarification on callCC

My background is Javascript, Python & a bit of Haskell. Hi I am new to Scheme (1 day old). I want to understand the difference between below 2 code snippets. (define onePlus (lambda (v) (+ 1 v))) (onePlus 4) ; 5 With CallCC (define anotherOnePlus…
Pawan Kumar
  • 1,443
  • 2
  • 16
  • 30
0
votes
2 answers

Is CallCC an improved version of goto?

My background is Javascript, Python & a bit of Haskell. I am trying to understand callCC, there are many explanations but I can't find them trivial & I came across this https://www.cs.bham.ac.uk/~hxt/research/Logiccolumn8.pdf and I felt like I…
Pawan Kumar
  • 1,443
  • 2
  • 16
  • 30
0
votes
1 answer

How can we convert between a program using `call/cc` and a program using functions written in CPS?

The Scheme Programming Language says It turns out that any program that uses call/cc can be rewritten in CPS without call/cc, but a total rewrite of the program (sometimes including even system-defined primitives) might be necessary. What are…
user10082400
0
votes
1 answer

Is there macros for rewrite CPS?

For example I have two async methods (get-a 10 (lambda (a) (get-b a (lambda (b) (display b))) but I want to write something similar to (define (a (get-a 10))) (define (b (get-b a))) (display b)
0
votes
1 answer

How does this callcc example work?

(callcc (fun k -> k 7)) + 3 (callcc (fun k -> 7)) + 3 What do each of these evaluate to and why?
Jake
  • 1
0
votes
1 answer

How does this call/cc expression work?

I am trying this on Racket and it gives out the answer as 5. But I cannot seem to figure out how it got to the answer. ((call/cc call/cc) (lambda (x) 5)) I expanded it as follows. ((call/cc (lambda (k) (call/cc (lambda (k1) (k k1))))) (lambda (x)…
budchan chao
  • 327
  • 3
  • 15
0
votes
1 answer

scheme: how to use call/cc for backtracking

I have been playing around with continuations in scheme (specifically guile) over the last couple of days and am a little puzzled by the results that some of the functions have and was wondering if anyone could explain exactly what is going on…
0
votes
2 answers

Scheme call/cc issue - implementing exit.

I am writing a program that needs to recursively analyze a list of "commands" and "programs" (it is an interpreter of some "robotic language" invented by our professor for a robot living in a maze). Because my initial implementation was too slow, I…
petajamaja
  • 520
  • 2
  • 9
  • 26
0
votes
1 answer

Magic Squares in Scheme

I am still new to Scheme and trying to solve the magic squares via call/cc and the amb operator. Currently, it is printing out: 1 1 1 31 Row 1 16 16 1 1 Row 2 16 1 16 1 Row 3 1 16 16 1 Row 4 I can't figure out why it is only using those numbers.…
OhioState22
  • 43
  • 1
  • 5
1 2 3 4 5
6