Skip to content

Instantly share code, notes, and snippets.

View l3gacyb3ta's full-sized avatar
😺
uwu

Arcade Wise l3gacyb3ta

😺
uwu
View GitHub Profile
@l3gacyb3ta
l3gacyb3ta / fujamie.prolog
Created October 17, 2023 19:03
Little SWI Prolog thing, for an IMPOSIBLE MATH QUESTION. Jamie you're the worst.
even(X) :- 0 is mod(X, 2).
odd(X) :- 1 is mod(X, 2).
sumofdigits(X, X) :- X<10.
sumofdigits(X, Y) :- X>=10, X1 is X // 10, X2 is X mod 10, sumofdigits(X1, Y1), Y is Y1 + X2.
digit_sum(N, Base, Sum):-
digit_sum(N, Base, Sum, 0).
<> (explode x) (Function (x))
<> (explode y) (Function (y))
<> (explode ?*) (Function (?*))
<> (implode String ?*) (?*)
<> (apply ?a to ?b) (eval (explode ?b) : ?a result ())
<> ((\x.?b)?c) (apply ?c to ?b)
<> (eval (Function (x ?t)) : ?a result ?c) (eval (Function ?t) : ?a result (?a ?c))
<> (eval (Function (x)) : ?a result ?c) (eval (Function DONE) : ?a result (?a ?c))
<> (eval (Function (?b ?t)) : ?a result ?c) (eval (Function ?t) : ?a result (?b ?c))
<> (eval (Function (?b)) : ?a result ?c) (eval (Function DONE) : ?a result (?b ?c))