This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callCC :: ((a -> Cont r b) -> Cont r a) -> Cont r a | |
callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tail_cps s k = k (tail s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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/"); |