Skip to content

Instantly share code, notes, and snippets.

@delbertooo
delbertooo / square.hs
Created Jul 30, 2012
callCC Beispiele
View square.hs
-- Without callCC
square :: Int -> Cont r Int
square n = return (n ^ 2)
-- With callCC
square :: Int -> Cont r Int
square n = callCC $ \k -> k (n ^ 2)
@delbertooo
delbertooo / callcc.hs
Created Jul 30, 2012
Cont Implementierung
View callcc.hs
callCC :: ((a -> Cont r b) -> Cont r a) -> Cont r a
callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k
View tail_cps.hs
tail_cps s k = k (tail s)
@delbertooo
delbertooo / gist:3207428
Created Jul 30, 2012
Additionsbeispiel im CPS
View gist:3207428
add :: Int -> Int -> Int
add x y = x + y
add_cps :: Int -> Int -> (Int -> r) -> r
add_cps x y k = k (add x y)
@delbertooo
delbertooo / testapp.c
Created Oct 6, 2011
Simple program using libspirit
View testapp.c
#include <stdio.h>
#include <stdlib.h>
#include <libspirit/spirit_news.h>
#include <libspirit/spirit_error.h>
int main(void) {
SPIRIT *spirit_handle;
SPIRITcode res;
spirit_handle = spirit_init("https://spirit.fh-schmalkalden.de/");