Skip to content

Instantly share code, notes, and snippets.

View webyrd's full-sized avatar

William E. Byrd webyrd

View GitHub Profile
@aphyr
aphyr / minikanren.pl
Created October 12, 2020 22:10
Minikanren in Lisp in Prolog
:- use_module(library(pairs)).
:- use_module(library(reif)).
not_in_list(K, L) :-
if_((L = []),
true,
([X | More] = L,
dif(K, X),
not_in_list(K, More))).
@danielsz
danielsz / fsm-ho.scm
Last active May 19, 2019 22:55
Refactoring of William Byrd's higher-order implementation of a finite state machine with driver
(define fsm-ho2
(lambda (str)
(letrec ([S0 (lambda (b)
(case b
[(0) S0]
[(1) S1]
[else #t]))]
[S1 (lambda (b)
(case b
[(0) S2]
( This is a simplified version of the card game War written in Puppy. )
( Simple version of War: )
( Two values on top of the stack represent dealt cards for the left and the )
( right players. Figure out which is bigger, and send the cards to that )
( player. In case of a tie, play again to determine the winner. )
( Puppy is an unimplemented point-free, concatentative, stack-based language )
( with quotations. )