This file contains hidden or 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-atom '&self ('coffee 'moka))) | |
(! (add-atom '&self ('coffee 'turkish))) | |
(= (myMultiFunction 'moka) ('moka 'good)) | |
(= (myMultiFunction 'moka) ('moka 'excellent)) | |
(! (Let w (superpose ('big 'small myMultiFunction)) | |
(Match '&self ('coffee x) (w x)))) | |
Output: | |
;[((big turkish)), ((big moka)), ((small turkish)), ((small moka)), ((moka excellent)), ((moka good))] |
This file contains hidden or 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
(coffee moka) | |
(coffee turkish) | |
(coffee expresso) | |
(coffee cappuccino) | |
(coffee latte) | |
!(match &self (coffee $1) $1) |
This file contains hidden or 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
(define %coffee | |
(%rel () | |
[('moka)] | |
[('turkish)] | |
[('expresso)] | |
[('cappuccino)] | |
[('latte)])) | |
(define (test data) | |
(if data |
This file contains hidden or 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.c */ | |
#include <stdio.h> | |
float add(float a, float b) { return a + b; } | |
//gcc -shared -o libadd.so add.c -fPIC | |
/* main.c */ | |
#include <stdio.h> | |
extern float add(float a, float b); | |
int main() { printf("Result: %f\n", add(3.0, 4.0)); return 0; } | |
//gcc main.c -L. -ladd |
This file contains hidden or 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
(let ((r392874 | |
(##core#inline_allocate | |
("C_a_i_list3" 9) | |
'Sentence | |
r393386 | |
r393390))) | |
(let ((r393221 | |
(##core#inline_allocate | |
("C_a_i_list2" 6) | |
'ExtSet |
This file contains hidden or 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
(define-syntax auto-list-helper | |
(syntax-rules () | |
((_ expr1 ()) ;empty list | |
(list expr1)) | |
((_ (expr1i ...) argi ...) ;a nested expression is not a procedure | |
(list (auto-list expr1i ...) (auto-list1 argi) ...)) | |
((_ expr1 argi ...) | |
(if (procedure? expr1) | |
(apply expr1 (list (auto-list1 argi) ...)) | |
(list (auto-list1 expr1) (auto-list1 argi) ...))))) |
This file contains hidden or 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
!(collapse (superpose ((superpose (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3)) | |
(superpose (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3)) | |
(superpose (4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6)) | |
(superpose (4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6)) | |
(superpose (7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9)) | |
(superpose (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3)) | |
(superpose (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3)) | |
(superpose (4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6)) | |
(superpose (4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6 4 5 6)) | |
(superpose (7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9 7 8 9)) |
This file contains hidden or 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
(: If (-> Bool Atom Atom)) | |
(= (If True $then) $then) | |
(= (If False $then) ()) | |
(: If (-> Bool Atom Atom Atom)) | |
(= (If $cond $then $else) (if $cond $then $else)) | |
(= (TupleConcat $Ev1 $Ev2) (collapse (superpose ((superpose $Ev1) (superpose $Ev2))))) | |
;safe expression equality | |
(: ==expr (-> Expression Expression Bool)) |
This file contains hidden or 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
(: sequential (-> Expression %Undefined%)) | |
(: TupleConcat (-> Expression Expression Expression)) | |
(= (TupleConcat $Ev1 $Ev2) (collapse (superpose ((superpose $Ev1) (superpose $Ev2))))) | |
(= (sequential $1) (superpose $1)) | |
(: do (-> Expression %Undefined%)) | |
(= (do $1) (case $1 ())) | |
(: If (-> Bool Atom Atom)) | |
(= (If True $then) $then) | |
(= (If False $then) ()) | |
(: If (-> Bool Atom Atom Atom)) |
This file contains hidden or 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 "microKanren.scm") | |
(define (squared x) (* x x)) | |
(define (main) | |
(define results | |
(run* (q) | |
(fresh (x y) | |
(== x 2) | |
(== y 3) |