Snippets tagged continuations
Continuation-Passing Mnemonics
Continuations provide a means whereby heap space can be traded for stack depth (heap space being generally more plentiful than stack depth). They are especially useful where tail recursion is not possible. Here are a couple of simple continuation examples that can be extended to cover more complex scenarios.
64 people like this
Posted: 1 years ago by Neil Carriersum the nodes in a (not-binary) tree using continuations
you can easily find how to use continuations to iterate over a binary tree but what if the count of children for each node is not known at design time? It's not so obvious how to do this in order to get a tail-recursive method. This short snippet shows how to do this to sum the values of every leaf. The second part demonstrates a general approach for other operations than addition.
21 people like this
Posted: 1 years ago by Carsten KönigFunctional Unparsing SQL
A combinator based DSL for composing type-safe parameterized sql queries. Inspired by Olivier Danvy's "Functional Unparsing" paper.
8 people like this
Posted: 10 months ago by Nick PalladinosIterateeCPS
An iteratee that uses continuation-passing style as an optimization. There is no more discriminated union, and the signature should feel familiar to those using Async.StartWithContinuations.
5 people like this
Posted: 9 months ago by Ryan Riley
Semi-Coroutine
This snippet implements a semi-coroutine by continuations.
2 people like this
Posted: 6 months ago by einblickerCoroutine
An implementation of Coroutine by using a continuation monad. it's using a monad library [1]. [1] https://github.com/fsharp/fsharpx
3 people like this
Posted: 8 months ago by einblickerDelimited Continuation Monad
Oleg's delimited continuation monad [1] and creating an external iterator from an internal iterator using it. [1] http://okmij.org/ftp/continuations/implementations.html#genuine-shift
3 people like this
Posted: 8 months ago by einblicker