trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
274 stars 13 forks source link

Works on Scryer but not Trealla #549

Closed infradig closed 5 months ago

infradig commented 5 months ago

Discussed in https://github.com/trealla-prolog/trealla/discussions/548

Originally posted by **jgarte** June 16, 2024 Hi, The following code works on Scryer but not on Trealla: ```prolog :- module(row, [is_twelve_tone_row/1]). :- use_module(library(clpz)). :- use_module(library(lists)). is_twelve_tone_row(Is) :- Is = [_,_,_,_,_,_,_,_,_,_,_,_], Is ins 0..11, permutation([0,1,2,3,4,5,6,7,8,9,10,11], Is). ``` ## In the `scryer-prolog` top-level ```prolog jgart@fedora:~/Code/prolog/logical-music$ scryer-prolog row.pl ?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,11]). true ; ... . ?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,Ns]). Ns = 11 ; ... . ?- ``` ## In the `tpl` top level ```prolog jgart@fedora:~/Code/prolog/logical-music$ tpl row.pl ?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,11]). throw(error(existence_error(procedure,permutation/2),permutation/2)). ?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,Ns]). throw(error(existence_error(procedure,permutation/2),permutation/2)). ``` It looks to me like `permutation/2` is not implemented in Trealla 🦆 From a quick lazy web UI search it looks like not 😢: ![image](https://github.com/trealla-prolog/trealla/assets/47760695/682d207e-4f2e-42e3-9f40-a253879ba235) Is anyone working on implementing `permutation/2` currently?
infradig commented 5 months ago

@jgarte

jgarte commented 5 months ago

@infradig Thanks!

It works perfectly now:

jgart@fedora:~/Code/prolog/logical-music$ tpl row.pl
?- is_twelve_tone_row([1,2,3,4,5,6,7,8,9,10,11]).
   false.
?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,11]).
   true
;
;
;
;  ... .
?- is_twelve_tone_row([0,1,2,3,4,5,6,7,8,9,10,Ns]).
   Ns = 11
;  ... .

https://git.sr.ht/~whereiseveryone/logical-music/tree/master/item/tonerow.pl

https://git.sr.ht/~whereiseveryone/logical-music/