• R/O
  • SSH

Joypy: List of commits

Main interpreter and library.


RSS
Rev. Time Author
e82375b0d716 tip 2019-07-22 03:50:27 Simon Forman

Messing with TLA+ in Prolog.

8825021cd713 2019-07-22 00:28:56 Simon Forman

Implement map combinator.

101d507003b8 2019-07-21 23:32:20 Simon Forman

Tiny edits. Almost nothing.

029a7b8c618a 2019-07-21 11:34:56 Simon Forman

Remove cuts from branch combinator.

f2d71c5ad139 2019-07-21 11:26:11 Simon Forman

Add mod, gcd, and hypot; term_expansion for math ops.

c0d894761421 2019-07-21 09:36:58 Simon Forman

Fold try_both_branches/4 into branch combo.

fa294f364037 2019-07-21 09:32:03 Simon Forman

Replace ≡ with plain ol' def/2.

As much fun as it was using ≡ as an operator, now that all the defs live in a text file you don't see it in the Prolog code anymore.

This way I get to use sweet sweet ASCII (except for the © symbol in the copyright notice.)

e270947ee8c7 2019-07-21 09:19:35 Simon Forman

WTF error handler.

Made it check that the unknown term really isn't a literal, definition, function, or combinator.

b85fe6c1d110 2019-07-21 08:57:19 Simon Forman

If I comment out the WTF handler...

...then the branch combinator works as intended. (Although the constraint-based stuff was also cool, it would have captured information from the comparison.)


?- joy(`[32 >] [++] [--] ifte`, Si, So).
Si = [_6598|_6600],
So = [_6598+1|_6600] ;
Si = [_6598|_6600],
So = [_6598-1|_6600] ;
false.

?- sjc(hmm, `[32 >] [++] [--] ifte`).
func(hmm, [A|B], [A+1|B]).
true ;
func(hmm, [A|B], [A-1|B]).
true ;
false.

dc6666877cd1 2019-07-21 08:45:28 Simon Forman

Try to handle expressions in branch combinator.

If the expression isn't 'true' or 'false' atoms then we assume it's a comparison expression and try to check its truth value.

If this fails then it will try both branches, to allow for e.g. compilation. THis almost works, but there's a choice point or something that gets hit before it tries the false path,

?- joy(` [32 >] [++] [--] ifte`, Si, So).
Si = [_2076|_2078],
So = [_2076+1|_2078] ;
wtf? +
Si = [_2076|_2078],
So = [[+], 1, _2076|_2078] ;
Si = [_2076|_2078],
So = [_2076-1|_2078] ;
wtf? -
Si = [_2076|_2078],
So = [[-], 1, _2076|_2078] ;
wtf? branch
Si = [_2076|_2078],
So = [[branch], [++], [--], _2076>32, _2076|_2078] ;
wtf? swap
Si = [_2076|_2078],
So = [[swap, branch], [--], [++], _2076>32, _2076|_2078] ;
wtf? first
Si = [_2076|_2078],
So = [[first, [++], [--], swap, branch], [_2076>32|_2078], _2076|_2078]


etc...

ff351c72293f 2019-07-21 08:38:48 Simon Forman

Handle exceptions in comparison ops.

You can't compare logic vars, so just bunt.

74a2447c4fe8 2019-07-17 01:53:48 Simon Forman

More readable genrec.

Explicit quoting is slightly more overhead but worth it I think to show what's going on more clearly.

624006d47b18 2019-07-17 01:46:55 Simon Forman

A little helper function to see compiled expressions.

Example from ordered binary tree notebook:

?- sjc(tree_add_Ee, `pop swap rolldown rrest ccons`).
func(tree_add_Ee, [_, [_, _|C], A, B|D], [[A, B|C]|D]).
true .

27f9aa8c4be8 2019-07-17 00:59:24 Simon Forman

Clear out CLP(FD) functions.

I like them but then you are constrained (pun intended) to only using integers. I'll probably bring them back at some point, either as an alternate implementation or their own commands.

e36e5c99c757 2019-07-17 00:42:45 Simon Forman

Opps! Here's the implementation of bool.

a93b3f3743c4 2019-07-17 00:41:28 Simon Forman

Add bool function to mimic Python semantics.

15eb946b7887 2019-07-16 15:02:08 Simon Forman

Change comparison ops to not use CLP(FD).

aaab55ef2527 2019-07-16 12:55:41 Simon Forman

Implement genrec combinator.

90b994dcbb48 2019-07-16 12:55:11 Simon Forman

Minor cleanup of defs.

3096787a1234 2019-07-16 08:11:49 Simon Forman

Move all definitions to defs.txt.

cc831a1b005c 2019-07-16 08:01:59 Simon Forman

Retract previous definitions before asserting new ones.

992c8dda18ab 2019-07-16 07:53:07 Simon Forman

Load definitions from a file.

This paves the way to regularize the defs between Python and Prolog (and and future other) implementations.

f4ede71d5067 2019-07-16 07:50:22 Simon Forman

Very minor docs change.

e3187f3d4123 2019-07-16 04:53:48 Simon Forman

Parse joy definitions from text.

This way a definitions file can be shared between Python Joy and Prolog Joy.

d3b42dfd8a60 2019-07-16 04:28:01 Simon Forman

New combinator infrst == infra first

Three uses means it's time for a refactor.

ab35da49303e 2019-07-16 03:20:13 Simon Forman

nullary combinator as definition.

That eliminates all the recursive calls to thun/3 (outside of thun itself, which is tail recursive.) That means that this Joy interpreter is now fully CPS.

All state is contained in the stack and expression, nothing is hidden in the Prolog "call stack".

6fd5d95f0a45 2019-07-15 15:02:10 Simon Forman

Infra as definition.

5afe5b816e4c 2019-07-15 14:48:18 Simon Forman

Reimplement app1 and app2 as definitions.

This eliminates three recursive calls to thun/3.

fa3b1c7e23d4 2019-07-15 13:58:20 Simon Forman

Got enough definitions, sort them.

9a63081793fe 2019-07-15 13:14:50 Simon Forman

Switch to symbolic math (from CLP(FD).)

A wee bit of error reporting of unknown terms.

New functions: pm plus-or-minus and neg negate; new combinator dupdip.

Show on old repository browser