Skip to content

Instantly share code, notes, and snippets.

@delbertooo
delbertooo / testapp.c
Created October 6, 2011 17:03
Simple program using libspirit
#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/");
@delbertooo
delbertooo / gist:3207428
Created July 30, 2012 14:42
Additionsbeispiel im CPS
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)
tail_cps s k = k (tail s)
@delbertooo
delbertooo / callcc.hs
Created July 30, 2012 15:07
Cont Implementierung
callCC :: ((a -> Cont r b) -> Cont r a) -> Cont r a
callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k
@delbertooo
delbertooo / square.hs
Created July 30, 2012 15:14
callCC Beispiele
-- 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)