Last active
December 12, 2015 06:58
-
-
Save nisbus/4733088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| note(a). | |
| note(b). | |
| note(c). | |
| %note(d). | |
| %note(e). | |
| %note(f). | |
| %note(g). | |
| %note(csharp). | |
| %note(asharp). | |
| %note(dsharp). | |
| %note(fsharp). | |
| notes(X) :- | |
| bagof(N, note(N),X). | |
| next_note(X) :- | |
| notes(Y), | |
| length(Y,Length), | |
| random(0,Length,Index), | |
| nth0(Index,Y,X). | |
| pattern(notes,Length,_Constraint,R) :- | |
| get_note_list(Length,Length,R). | |
| get_note_list(0,_,R):- | |
| !,R. | |
| get_note_list(X,X,Res) :- | |
| NewX is X-1, | |
| next_note(Res), | |
| get_note_list(NewX,X,[Res]). | |
| get_note_list(X,T,R) :- | |
| NewX is X-1, | |
| next_note(Y), | |
| Res = [Y|R], | |
| get_note_list(NewX,T,Res). | |
| %%%SHOULD BE | |
| get_note_list(0,_). | |
| get_note_list(N,Out) :- | |
| NewN is N-1, | |
| next_note(Res), | |
| get_note_list(NewN,R), | |
| Out = [Res|R],!. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment