OSDN Git Service

joypy/Thun.git
4 years agoThat works nicely, again.
Simon Forman [Sat, 9 Nov 2019 21:42:14 +0000 (13:42 -0800)]
That works nicely, again.

4 years agoConvert to ? DCG and it's macro-time!
Simon Forman [Sat, 9 Nov 2019 21:34:51 +0000 (13:34 -0800)]
Convert to ? DCG and it's macro-time!

4 years agoI think that does it for cons.
Simon Forman [Sat, 9 Nov 2019 20:14:51 +0000 (12:14 -0800)]
I think that does it for cons.

Offsets in pair records can be negative.

4 years agoThat's the mainloop converted to permit negative offsets.
Simon Forman [Sat, 9 Nov 2019 20:03:13 +0000 (12:03 -0800)]
That's the mainloop converted to permit negative offsets.

4 years agoMinor cleanup, bug fixes.
Simon Forman [Sat, 9 Nov 2019 19:27:29 +0000 (11:27 -0800)]
Minor cleanup, bug fixes.

4 years agoMinor bugfix.
Simon Forman [Fri, 8 Nov 2019 23:24:09 +0000 (15:24 -0800)]
Minor bugfix.

asr not ror.

4 years agoCons
Simon Forman [Fri, 8 Nov 2019 22:06:28 +0000 (14:06 -0800)]
Cons

4 years agoJust do it in asm.
Simon Forman [Fri, 8 Nov 2019 16:08:53 +0000 (08:08 -0800)]
Just do it in asm.

4 years agohmm...
Simon Forman [Fri, 8 Nov 2019 04:21:26 +0000 (20:21 -0800)]
hmm...

4 years agoWIth push2 finished that's the mainloop converted.
Simon Forman [Fri, 8 Nov 2019 01:25:04 +0000 (17:25 -0800)]
WIth push2 finished that's the mainloop converted.

4 years agolookup
Simon Forman [Fri, 8 Nov 2019 00:28:28 +0000 (16:28 -0800)]
lookup

4 years agoif_literal
Simon Forman [Fri, 8 Nov 2019 00:15:41 +0000 (16:15 -0800)]
if_literal

4 years agoA start on converting the mainloop.
Simon Forman [Thu, 7 Nov 2019 23:53:07 +0000 (15:53 -0800)]
A start on converting the mainloop.

4 years agoTake two on the compiler.
Simon Forman [Thu, 7 Nov 2019 22:57:41 +0000 (14:57 -0800)]
Take two on the compiler.

4 years agoMinor cleanup.
Simon Forman [Thu, 7 Nov 2019 15:55:01 +0000 (07:55 -0800)]
Minor cleanup.

4 years agoModify error reporting a lil; words word.
Simon Forman [Thu, 7 Nov 2019 15:54:04 +0000 (07:54 -0800)]
Modify error reporting a lil; words word.

4 years agoDefinition of ii combinator.
Simon Forman [Thu, 7 Nov 2019 15:53:21 +0000 (07:53 -0800)]
Definition of ii combinator.

    ii == [dip] dupdip i

         a [F] ii
      --------------
          F a F

4 years agoCall for_serial/2
Simon Forman [Thu, 7 Nov 2019 15:43:21 +0000 (07:43 -0800)]
Call for_serial/2

4 years agoUsing partial deduction to inline literals, functions, and combinators.
Simon Forman [Thu, 22 Aug 2019 22:45:24 +0000 (15:45 -0700)]
Using partial deduction to inline literals, functions, and combinators.

4 years agominor cleanup
Simon Forman [Wed, 21 Aug 2019 05:00:27 +0000 (22:00 -0700)]
minor cleanup

4 years agosmall func recognizes [] and [X].
Simon Forman [Tue, 20 Aug 2019 05:02:06 +0000 (22:02 -0700)]
small func recognizes [] and [X].

4 years agoRename bar to korf and some docs.
Simon Forman [Sun, 18 Aug 2019 23:59:31 +0000 (16:59 -0700)]
Rename bar to korf and some docs.

4 years agominor cleanup
Simon Forman [Sun, 18 Aug 2019 19:17:37 +0000 (12:17 -0700)]
minor cleanup

4 years agoreintroduce definition of fork; it doesn't shadow func(fork, ...).
Simon Forman [Sun, 18 Aug 2019 18:47:48 +0000 (11:47 -0700)]
reintroduce definition of fork; it doesn't shadow func(fork, ...).

4 years agoread child output after local thun/3
Simon Forman [Sun, 18 Aug 2019 18:09:36 +0000 (11:09 -0700)]
read child output after local thun/3

4 years agotruly fork, sort of
Simon Forman [Sun, 18 Aug 2019 17:53:25 +0000 (10:53 -0700)]
truly fork, sort of

4 years agominor cleanup
Simon Forman [Tue, 13 Aug 2019 18:58:31 +0000 (11:58 -0700)]
minor cleanup

4 years agoMinor cleanup.
Simon Forman [Tue, 13 Aug 2019 18:51:41 +0000 (11:51 -0700)]
Minor cleanup.

4 years agoMove DCG stuff to own file.
Simon Forman [Tue, 13 Aug 2019 18:48:08 +0000 (11:48 -0700)]
Move DCG stuff to own file.

4 years agoParse ints; move line/{1,2} to main.pl.
Simon Forman [Tue, 13 Aug 2019 18:29:49 +0000 (11:29 -0700)]
Parse ints; move line/{1,2} to main.pl.

4 years agoParse floating point numbers.
Simon Forman [Tue, 13 Aug 2019 18:24:28 +0000 (11:24 -0700)]
Parse floating point numbers.

4 years agominor cleanup
Simon Forman [Tue, 13 Aug 2019 05:29:09 +0000 (22:29 -0700)]
minor cleanup

4 years agominor cleanup
Simon Forman [Tue, 13 Aug 2019 04:59:19 +0000 (21:59 -0700)]
minor cleanup

4 years agoNumbers can be followed by space or [.
Simon Forman [Tue, 13 Aug 2019 04:29:26 +0000 (21:29 -0700)]
Numbers can be followed by space or [.

4 years agoParse negative numbers.
Simon Forman [Tue, 13 Aug 2019 04:13:11 +0000 (21:13 -0700)]
Parse negative numbers.

4 years agoswapd function
Simon Forman [Tue, 13 Aug 2019 04:08:35 +0000 (21:08 -0700)]
swapd function

4 years agoassert_defs/1 got upset about not finding combo/5
Simon Forman [Tue, 13 Aug 2019 04:08:17 +0000 (21:08 -0700)]
assert_defs/1 got upset about not finding combo/5

4 years agoMinor cleanup of the parser.
Simon Forman [Tue, 13 Aug 2019 03:59:02 +0000 (20:59 -0700)]
Minor cleanup of the parser.

4 years agorework parser DCGs
Simon Forman [Tue, 13 Aug 2019 03:12:35 +0000 (20:12 -0700)]
rework parser DCGs

4 years agoOops! Regression.
Simon Forman [Tue, 13 Aug 2019 02:25:13 +0000 (19:25 -0700)]
Oops! Regression.

4 years agominor cleanup
Simon Forman [Tue, 13 Aug 2019 02:17:15 +0000 (19:17 -0700)]
minor cleanup

4 years agoswoncat and fiddling with parser.
Simon Forman [Tue, 13 Aug 2019 02:09:49 +0000 (19:09 -0700)]
swoncat and fiddling with parser.

4 years agoExperiment with putting logic vars on the stack.
Simon Forman [Mon, 12 Aug 2019 04:30:02 +0000 (21:30 -0700)]
Experiment with putting logic vars on the stack.

4 years agoRemove a cut that sucked.
Simon Forman [Mon, 12 Aug 2019 03:45:49 +0000 (20:45 -0700)]
Remove a cut that sucked.

4 years agounstack, least_fraction
Simon Forman [Mon, 12 Aug 2019 02:57:28 +0000 (19:57 -0700)]
unstack, least_fraction

4 years agoCopyright notices.
Simon Forman [Mon, 12 Aug 2019 02:41:11 +0000 (19:41 -0700)]
Copyright notices.

4 years agoThe sqrt/1 predicate wasn't working.
Simon Forman [Mon, 12 Aug 2019 02:35:05 +0000 (19:35 -0700)]
The sqrt/1 predicate wasn't working.

4 years agoMultifile func/3.
Simon Forman [Mon, 12 Aug 2019 01:45:57 +0000 (18:45 -0700)]
Multifile func/3.

4 years agoBuild math & comparision functions.
Simon Forman [Mon, 12 Aug 2019 00:48:29 +0000 (17:48 -0700)]
Build math & comparision functions.

4 years agoClean up REPL formatting.
Simon Forman [Mon, 12 Aug 2019 00:00:38 +0000 (17:00 -0700)]
Clean up REPL formatting.

4 years agoDon't shadow funcs and combos.
Simon Forman [Sun, 11 Aug 2019 22:12:56 +0000 (15:12 -0700)]
Don't shadow funcs and combos.

4 years agoDon't shadow funcs & combos.
Simon Forman [Sun, 11 Aug 2019 21:56:20 +0000 (14:56 -0700)]
Don't shadow funcs & combos.

4 years agoExtract mainloop to own file.
Simon Forman [Sun, 11 Aug 2019 21:51:13 +0000 (14:51 -0700)]
Extract mainloop to own file.

4 years agoUse double-quoted string for codes.
Simon Forman [Sun, 11 Aug 2019 05:21:57 +0000 (22:21 -0700)]
Use double-quoted string for codes.

4 years agocleanup old files
Simon Forman [Sun, 11 Aug 2019 05:07:17 +0000 (22:07 -0700)]
cleanup old files

4 years agoBuild defs.pl from defs.txt.
Simon Forman [Sun, 11 Aug 2019 05:03:44 +0000 (22:03 -0700)]
Build defs.pl from defs.txt.

4 years agobuild defs.pl
Simon Forman [Sun, 11 Aug 2019 04:46:48 +0000 (21:46 -0700)]
build defs.pl

4 years agobuild defs.pl
Simon Forman [Sun, 11 Aug 2019 04:45:59 +0000 (21:45 -0700)]
build defs.pl

4 years agoMove parser to own file.
Simon Forman [Sun, 11 Aug 2019 03:57:11 +0000 (20:57 -0700)]
Move parser to own file.

4 years agomap combo
Simon Forman [Sun, 11 Aug 2019 03:42:48 +0000 (20:42 -0700)]
map combo

4 years agoBring in funcs and combos.
Simon Forman [Sun, 11 Aug 2019 03:12:41 +0000 (20:12 -0700)]
Bring in funcs and combos.

4 years agoOmit Prolog toplevel.
Simon Forman [Sun, 11 Aug 2019 03:06:12 +0000 (20:06 -0700)]
Omit Prolog toplevel.

4 years agoDo not need thses files.
Simon Forman [Sun, 11 Aug 2019 03:03:52 +0000 (20:03 -0700)]
Do not need thses files.

4 years agoFold in parser, main loop, and support.
Simon Forman [Sun, 11 Aug 2019 02:57:00 +0000 (19:57 -0700)]
Fold in parser, main loop, and support.

4 years agoRename foo to thun.
Simon Forman [Sun, 11 Aug 2019 02:25:48 +0000 (19:25 -0700)]
Rename foo to thun.

4 years agoMake a version for GNU Prolog compiler.
Simon Forman [Sat, 10 Aug 2019 19:19:09 +0000 (12:19 -0700)]
Make a version for GNU Prolog compiler.

4 years agoAlso don't shadow combinators.
Simon Forman [Fri, 9 Aug 2019 23:58:34 +0000 (16:58 -0700)]
Also don't shadow combinators.

(I realized that the way defs are parsed now means that each def
(but the last) is first asserted with the wrong definition expression
(it includes the symbol of the following definition at the end) and
then the parser figures out that there's another defintion following
and re-asserts the correct expression.  It would be nice to fix that
but it's kind of a PITA.  I used to build a list of definitions and
then assert them all at the end.  For now there aren't enough defs to
justify the extra work.

4 years agoPrevent definitions from shadowing functions.
Simon Forman [Fri, 9 Aug 2019 23:53:40 +0000 (16:53 -0700)]
Prevent definitions from shadowing functions.

4 years agoDemo grow/shrink.
Simon Forman [Fri, 9 Aug 2019 23:37:33 +0000 (16:37 -0700)]
Demo grow/shrink.

4 years agoSome trailing whitespace or something.
Simon Forman [Fri, 9 Aug 2019 16:28:15 +0000 (09:28 -0700)]
Some trailing whitespace or something.

4 years agoA few more functions.
Simon Forman [Fri, 9 Aug 2019 14:26:37 +0000 (07:26 -0700)]
A few more functions.

reverse, shift, shunt, take, split_at

4 years agomerge
Simon Forman [Thu, 8 Aug 2019 06:36:38 +0000 (23:36 -0700)]
merge

4 years agogrow/shrink as DCGs.
Simon Forman [Thu, 8 Aug 2019 06:28:28 +0000 (23:28 -0700)]
grow/shrink as DCGs.

4 years agoInteger DCGs that work in both directions.
Simon Forman [Wed, 7 Aug 2019 18:40:49 +0000 (11:40 -0700)]
Integer DCGs that work in both directions.

4 years agoloop combinator handles ambiguity.
Simon Forman [Sun, 4 Aug 2019 16:28:01 +0000 (09:28 -0700)]
loop combinator handles ambiguity.

remove some old notes.

4 years agoMove is_numerical() to joy.gui.utils.
Simon Forman [Sun, 4 Aug 2019 02:02:24 +0000 (19:02 -0700)]
Move is_numerical() to joy.gui.utils.

4 years agoExperiment in formatting stacks for output.
Simon Forman [Sun, 4 Aug 2019 02:01:45 +0000 (19:01 -0700)]
Experiment in formatting stacks for output.

Tracing, sort of...

4 years agoMinor refactor.
Simon Forman [Sun, 4 Aug 2019 02:01:00 +0000 (19:01 -0700)]
Minor refactor.

crbo/4 to to_fixed_point/3

4 years agoGnarly fun with metaprogramming.
Simon Forman [Sun, 4 Aug 2019 00:56:25 +0000 (17:56 -0700)]
Gnarly fun with metaprogramming.

4 years agoGet the path separator right on windows.
Simon Forman [Sat, 3 Aug 2019 01:30:43 +0000 (18:30 -0700)]
Get the path separator right on windows.

It used to use: C:\Users\sforman/.joypy

which worked, but ew.

4 years agoComparisions are literals too.
Simon Forman [Mon, 22 Jul 2019 17:25:34 +0000 (10:25 -0700)]
Comparisions are literals too.

Also a bunch of reformatting.

Maybe I can modify the term_expansion/2 to also write the literal/1 clauses for math and comps?

4 years agoBits of formatting.
Simon Forman [Mon, 22 Jul 2019 17:04:32 +0000 (10:04 -0700)]
Bits of formatting.

4 years agoMinor cleanup.
Simon Forman [Mon, 22 Jul 2019 01:48:11 +0000 (18:48 -0700)]
Minor cleanup.

4 years agoRemove write_state/5.
Simon Forman [Mon, 22 Jul 2019 00:56:34 +0000 (17:56 -0700)]
Remove write_state/5.

4 years agoBuild a list of the moves taken.
Simon Forman [Mon, 22 Jul 2019 00:55:19 +0000 (17:55 -0700)]
Build a list of the moves taken.

4 years agoRefactor a bit.
Simon Forman [Mon, 22 Jul 2019 00:25:22 +0000 (17:25 -0700)]
Refactor a bit.

4 years agoAssert definitions as they are read.
Simon Forman [Sun, 21 Jul 2019 21:13:48 +0000 (14:13 -0700)]
Assert definitions as they are read.

Instead of building a list then asserting them all after parsing.

5 years agoMessing with TLA+ in Prolog.
Simon Forman [Sun, 21 Jul 2019 18:50:27 +0000 (11:50 -0700)]
Messing with TLA+ in Prolog.

5 years agoImplement map combinator.
Simon Forman [Sun, 21 Jul 2019 15:28:56 +0000 (08:28 -0700)]
Implement map combinator.

5 years agoTiny edits. Almost nothing.
Simon Forman [Sun, 21 Jul 2019 14:32:20 +0000 (07:32 -0700)]
Tiny edits.  Almost nothing.

5 years agoRemove cuts from branch combinator.
Simon Forman [Sun, 21 Jul 2019 02:34:56 +0000 (19:34 -0700)]
Remove cuts from branch combinator.

5 years agoAdd mod, gcd, and hypot; term_expansion for math ops.
Simon Forman [Sun, 21 Jul 2019 02:26:11 +0000 (19:26 -0700)]
Add mod, gcd, and hypot; term_expansion for math ops.

5 years agoFold try_both_branches/4 into branch combo.
Simon Forman [Sun, 21 Jul 2019 00:36:58 +0000 (17:36 -0700)]
Fold try_both_branches/4 into branch combo.

5 years agoReplace ? with plain ol' def/2.
Simon Forman [Sun, 21 Jul 2019 00:32:03 +0000 (17:32 -0700)]
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.)

5 years agoWTF error handler.
Simon Forman [Sun, 21 Jul 2019 00:19:35 +0000 (17:19 -0700)]
WTF error handler.

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

5 years agoIf I comment out the WTF handler...
Simon Forman [Sat, 20 Jul 2019 23:57:19 +0000 (16:57 -0700)]
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.

5 years agoTry to handle expressions in branch combinator.
Simon Forman [Sat, 20 Jul 2019 23:45:28 +0000 (16:45 -0700)]
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...

5 years agoHandle exceptions in comparison ops.
Simon Forman [Sat, 20 Jul 2019 23:38:48 +0000 (16:38 -0700)]
Handle exceptions in comparison ops.

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

5 years agoMore readable genrec.
Simon Forman [Tue, 16 Jul 2019 16:53:48 +0000 (09:53 -0700)]
More readable genrec.

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

5 years agoA little helper function to see compiled expressions.
Simon Forman [Tue, 16 Jul 2019 16:46:55 +0000 (09:46 -0700)]
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 .