# twelve.pl -rw-r--r-- 1.6 KiB View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
twelve_tone_row([P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12]) :-
    all_different([P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12]),
    valid_pitches([P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12]).

all_different([]).
all_different([H|T]) :-
    \+ member(H, T),
    all_different(T).

valid_pitches(Row) :-
    valid_pitches(Row, [c,cs,d,ds,e,f,fs,g,gs,a,as,b]).

valid_pitches([], ValidPitches).
valid_pitches([H|T], ValidPitches) :-
    member(H, ValidPitches),
    valid_pitches(T, ValidPitches).

% ?- member(c, [c,cs,d,ds,e,f,fs,g,gs]).
%@    true
%@ ;  false.

% ?- valid_pitches([c]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g,gs]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g,gs,a]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g,gs,a,as]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g,gs,a,as,b]).
%@    true
%@ ;  false.

% ?- valid_pitches([c,cs,d,ds,e,f,g,gs,a,as,b,z]).
%@    false.

% ?- phrase(twelve_tone_row, [c,e,g,b,cs,ds,fs,gs,as,d,f,a]).

% ?- phrase(twelve_tone_row, [c,cs,d,ds,e,f,fs,g,gs,a,as,b]).

% ?- all_different([c,cs,d,ds,e,f,fs,g,gs,a,as,b]).

% ?- valid_pitches([c,cs,d,ds,e,f,fs,g,gs,a,as,b]).

% ?- valid_pitches([c,cs], [c,cs,d,ds,e,f,fs,g,gs,a,as,b]).

% ?- valid_pitches([c,cs], VP).
%@