Commit ad17f734 authored by Michal Terepeta's avatar Michal Terepeta Committed by Ben Gamari

spectral: remove salishan

There's no Haskell code in `spectral/salishan`, so let's just remove it.
Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>

Test Plan: build & run

Reviewers: bgamari

Subscribers: snowleopard

Differential Revision: https://phabricator.haskell.org/D3321
parent 4f149ed3
......@@ -8,8 +8,7 @@ SUBDIRS = ansi atom awards banner boyer boyer2 calendar cichelli circsim \
puzzle rewrite scc simple sorting sphere treejoin
# compreals no suitable test data
# salishan no Haskell code!
OTHER_SUBDIRS = compreals lambda last-piece salishan secretary triangle
OTHER_SUBDIRS = compreals lambda last-piece secretary triangle
include $(TOP)/mk/target.mk
This source diff could not be displayed because it is too large. You can view the blob instead.
T 1 1 0 %na=Boolean
T 2 1 1 %na=Character
T 3 1 2 %na=Double
T 4 1 3 %na=Integer
T 5 1 4 %na=Null
T 6 1 5 %na=Real
T 7 1 6 %na=WildBasic
T 8 10
T 9 0 4 %na=queue
T 10 0 9 %na=queue2
T 11 8 4 0
T 12 8 6 0
T 13 3 11 12
T 14 3 11 11
T 15 8 9 0
T 16 8 4 15
T 17 8 9 15
T 18 3 16 17
T 19 8 10 15
T 20 8 9 19
T 21 3 17 20
T 22 8 10 0
T 23 8 4 22
T 24 8 10 17
T 25 3 23 24
T 26 6 9
T 27 8 26 0
T 28 8 26 27
T 29 3 17 28
T 30 4 9
C$ C Faked IF1CHECK
C$ D Nodes are DFOrdered
C$ F Livermore Frontend Version1.8
I 13 "random" %sl=22
I 14 "next_seed" %sl=23
G 18 "well_persons" %sl=30
E 12 1 0 1 9 %mk=V
E 12 2 0 2 9 %mk=V
N 1 120 %sl=34
L 1 1 13 "random" %mk=V
E 0 1 1 2 4 %na=seed %mk=V %sl=34
N 2 116 %sl=35
E 0 2 2 1 9 %na=patients %mk=V %sl=35
N 3 124 %sl=38
E 1 1 3 1 6 %na=x %mk=V %sl=38
L 3 2 6 "0.7" %mk=V
N 4 151 %sl=36
E 2 1 4 1 4 %na=size %mk=V %sl=36
N 5 124 %sl=38
E 2 1 5 1 4 %na=size %mk=V %sl=38
L 5 2 4 "0" %mk=V
N 6 152 %sl=36
E 4 1 6 1 6 %mk=V
E 1 1 6 2 6 %na=x %mk=V %sl=36
N 7 141 %sl=38
E 5 1 7 1 1 %mk=V
E 3 1 7 2 1 %mk=V
N 8 122 %sl=36
E 6 1 8 1 6 %mk=V
L 8 2 6 "0.7" %mk=V
N 9 128 %sl=36
E 8 1 9 1 6 %mk=V
N 10 141 %sl=36
E 9 1 10 1 4 %mk=V
L 10 2 4 "1" %mk=V
N 11 129
E 7 1 11 1 1 %mk=V
{ Compound 12 1
G 0
E 0 1 0 1 4 %mk=V
G 0 %sl=40
E 5 1 0 1 9 %mk=V
E 4 1 0 2 9 %mk=V
N 1 105 %sl=41
E 0 2 1 1 9 %na=patients %mk=V %sl=41
E 0 4 1 2 4 %na=size %mk=V %sl=41
N 2 105 %sl=42
E 0 2 2 1 9 %na=patients %mk=V %sl=42
E 0 3 2 2 4 %na=sick %mk=V %sl=42
N 3 113 %sl=41
E 0 2 3 1 9 %na=patients %mk=V %sl=41
E 0 3 3 2 4 %na=sick %mk=V %sl=41
E 1 1 3 3 4 %mk=V
N 4 103 %sl=42
L 4 1 4 "1" %mk=V
E 2 1 4 2 4 %mk=V
N 5 111 %sl=41
E 3 1 5 1 9 %mk=V
G 0 %sl=39
E 0 2 0 1 9 %na=patients %mk=V %sl=39
E 1 1 0 2 9 %mk=V
N 1 103 %sl=39
L 1 1 4 "1" %mk=V
} 12 1 3 0 1 2 %sl=39
E 11 1 12 1 4 %mk=V
E 0 2 12 2 9 %na=patients %mk=V %sl=39
E 10 1 12 3 4 %na=sick %mk=V %sl=41
E 2 1 12 4 4 %na=size %mk=V %sl=41
G 21 "nurse" %sl=56
E 7 1 0 1 9 %mk=V
E 7 2 0 2 10 %mk=V
E 7 3 0 3 9 %mk=V
N 1 116 %sl=60
E 0 1 1 1 9 %na=patients %mk=V %sl=60
N 2 116 %sl=61
E 0 2 2 1 9 %na=doctors %mk=V %sl=61
N 3 124 %sl=63
E 1 1 3 1 4 %na=n_patients %mk=V %sl=63
L 3 2 4 "0" %mk=V
N 4 124 %sl=63
E 2 1 4 1 4 %na=n_doctors %mk=V %sl=63
L 4 2 4 "0" %mk=V
N 5 141 %sl=63
E 3 1 5 1 1 %mk=V
E 4 1 5 2 1 %mk=V
N 6 129
E 5 1 6 1 1 %mk=V
{ Compound 7 1
G 0
E 0 1 0 1 4 %mk=V
G 0 %sl=65
E 5 1 0 1 9 %mk=V
E 8 1 0 2 10 %mk=V
E 7 1 0 3 9 %mk=V
N 1 112 %sl=66
E 0 2 1 1 9 %na=patients %mk=V %sl=66
N 2 105 %sl=67
E 0 2 2 1 9 %na=patients %mk=V %sl=67
L 2 2 4 "1" %mk=V
N 3 105 %sl=67
E 0 3 3 1 9 %na=doctors %mk=V %sl=67
L 3 2 4 "1" %mk=V
N 4 112 %sl=68
E 0 3 4 1 9 %na=doctors %mk=V %sl=68
N 5 115 %sl=66
E 1 1 5 1 9 %mk=V
L 5 2 4 "1" %mk=V
N 6 103 %sl=67
L 6 1 4 "1" %mk=V
E 2 1 6 2 4 %mk=V
E 3 1 6 3 4 %mk=V
N 7 115 %sl=68
E 4 1 7 1 9 %mk=V
L 7 2 4 "1" %mk=V
N 8 103 %sl=67
L 8 1 4 "1" %mk=V
E 6 1 8 2 9 %mk=V
G 0 %sl=64
E 0 2 0 1 9 %na=patients %mk=V %sl=64
E 1 1 0 2 10 %mk=V
E 0 3 0 3 9 %na=doctors %mk=V %sl=64
N 1 103 %sl=64
L 1 1 4 "1" %mk=V
} 7 1 3 0 1 2 %sl=64
E 6 1 7 1 4 %mk=V
E 0 1 7 2 9 %na=patients %mk=V %sl=64
E 0 2 7 3 9 %na=doctors %mk=V %sl=64
G 25 "examinations" %sl=80
E 13 1 0 1 10 %mk=V
E 13 2 0 2 9 %mk=V
E 13 3 0 3 9 %mk=V
N 1 120 %sl=84
L 1 1 13 "random" %mk=V
E 0 1 1 2 4 %na=seed %mk=V %sl=84
N 2 109 %sl=85
E 0 2 2 1 10 %na=in_exam %mk=V %sl=85
N 3 131 %sl=88
E 1 1 3 1 6 %na=x %mk=V %sl=88
L 3 2 6 "0.3" %mk=V
N 4 151 %sl=86
E 2 1 4 1 4 %na=size %mk=V %sl=86
N 5 124 %sl=88
E 2 1 5 1 4 %na=size %mk=V %sl=88
L 5 2 4 "0" %mk=V
N 6 139 %sl=88
E 3 1 6 1 1 %mk=V
N 7 152 %sl=86
E 4 1 7 1 6 %mk=V
E 1 1 7 2 6 %na=x %mk=V %sl=86
N 8 141 %sl=88
E 5 1 8 1 1 %mk=V
E 6 1 8 2 1 %mk=V
N 9 122 %sl=86
E 7 1 9 1 6 %mk=V
L 9 2 6 "0.3" %mk=V
N 10 128 %sl=86
E 9 1 10 1 6 %mk=V
N 11 141 %sl=86
E 10 1 11 1 4 %mk=V
L 11 2 4 "1" %mk=V
N 12 129
E 8 1 12 1 1 %mk=V
{ Compound 13 1
G 0
E 0 1 0 1 4 %mk=V
G 0 %sl=90
E 9 1 0 1 10 %mk=V
E 7 1 0 2 9 %mk=V
E 8 1 0 3 9 %mk=V
N 1 105 %sl=91
E 0 2 1 1 10 %na=in_exam %mk=V %sl=91
E 0 4 1 2 4 %na=size %mk=V %sl=91
N 2 105
E 0 2 2 1 10 %na=in_exam %mk=V %sl=92
E 0 3 2 2 4 %na=cured %mk=V %sl=92
N 3 105 %sl=92
E 2 1 3 1 9 %mk=V
L 3 2 4 "1" %mk=V
N 4 105
E 0 2 4 1 10 %na=in_exam %mk=V %sl=93
E 0 3 4 2 4 %na=cured %mk=V %sl=93
N 5 105 %sl=93
E 4 1 5 1 9 %mk=V
L 5 2 4 "2" %mk=V
N 6 113 %sl=91
E 0 2 6 1 10 %na=in_exam %mk=V %sl=91
E 0 3 6 2 4 %na=cured %mk=V %sl=91
E 1 1 6 3 9 %mk=V
N 7 103 %sl=92
L 7 1 4 "1" %mk=V
E 3 1 7 2 4 %mk=V
N 8 103 %sl=93
L 8 1 4 "1" %mk=V
E 5 1 8 2 4 %mk=V
N 9 111 %sl=91
E 6 1 9 1 10 %mk=V
G 0 %sl=89
E 0 2 0 1 10 %na=in_exam %mk=V %sl=89
E 1 1 0 2 9 %mk=V
E 2 1 0 3 9 %mk=V
N 1 103 %sl=89
L 1 1 4 "1" %mk=V
N 2 103 %sl=89
L 2 1 4 "1" %mk=V
} 13 1 3 0 1 2 %sl=89
E 12 1 13 1 4 %mk=V
E 0 2 13 2 10 %na=in_exam %mk=V %sl=89
E 11 1 13 3 4 %na=cured %mk=V %sl=91
E 2 1 13 4 4 %na=size %mk=V %sl=91
X 29 "doctors_office" %sl=99
E 1 1 0 1 26 %mk=V
E 1 2 0 2 26 %mk=V
{ Compound 1 4
G 0 %sl=102
L 0 3 4 "0" %na=seed %mk=V %sl=103
E 4 1 0 4 9 %na=doctor_out %mk=V %sl=109
E 0 2 0 5 9 %na=still_available %mk=V %sl=108
E 5 1 0 6 10 %na=still_examining %mk=V %sl=110
E 3 1 0 7 9 %na=patient_in %mk=V %sl=107
E 2 1 0 8 9 %na=still_sick %mk=V %sl=106
E 0 1 0 9 9 %na=still_well %mk=V %sl=104
E 6 1 0 10 10 %na=patient_doctor %mk=V %sl=111
E 1 1 0 11 9 %na=patient_out %mk=V %sl=105
N 1 103 %sl=105
L 1 1 4 "1" %mk=V
N 2 103 %sl=106
L 2 1 4 "1" %mk=V
N 3 103 %sl=107
L 3 1 4 "1" %mk=V
N 4 103 %sl=109
L 4 1 4 "1" %mk=V
N 5 103 %sl=110
L 5 1 4 "1" %mk=V
N 6 103 %sl=111
L 6 1 4 "1" %mk=V
G 0 %sl=112
L 0 1 1 "true" %mk=V
G 0 %sl=113
E 1 1 0 3 4 %na=seed %mk=V %sl=120
E 8 3 0 4 9 %na=doctor_out %mk=V %sl=118
E 7 3 0 5 9 %na=still_available %mk=V %sl=118
E 8 1 0 6 10 %na=still_examining %mk=V %sl=120
E 6 2 0 7 9 %na=patient_in %mk=V %sl=117
E 7 1 0 8 9 %na=still_sick %mk=V %sl=117
E 6 1 0 9 9 %na=still_well %mk=V %sl=115
E 7 2 0 10 10 %na=patient_doctor %mk=V %sl=120
E 8 2 0 11 9 %na=patient_out %mk=V %sl=115
N 1 120 %sl=113
L 1 1 14 "next_seed" %mk=V
E 0 3 1 2 4 %na=old-seed %mk=V %sl=113
N 2 104 %sl=115
E 0 9 2 1 9 %na=old-still_well %mk=V %sl=115
E 0 11 2 2 9 %na=old-patient_out %mk=V %sl=115
N 3 104 %sl=117
E 0 8 3 1 9 %na=old-still_sick %mk=V %sl=117
E 0 7 3 2 9 %na=old-patient_in %mk=V %sl=117
N 4 104 %sl=118
E 0 5 4 1 9 %na=old-still_available %mk=V %sl=118
E 0 4 4 2 9 %na=old-doctor_out %mk=V %sl=118
N 5 104 %sl=120
E 0 6 5 1 10 %na=old-still_examining %mk=V %sl=120
E 0 10 5 2 10 %na=old-patient_doctor %mk=V %sl=120
N 6 120 %sl=115
L 6 1 18 "well_persons" %mk=V
E 1 1 6 2 4 %na=seed %mk=V %sl=115
E 2 1 6 3 9 %mk=V
N 7 120 %sl=117
L 7 1 21 "nurse" %mk=V
E 3 1 7 2 9 %mk=V
E 4 1 7 3 9 %mk=V
N 8 120 %sl=120
L 8 1 25 "examinations" %mk=V
E 1 1 8 2 4 %na=seed %mk=V %sl=120
E 5 1 8 3 10 %mk=V
G 0 %sl=121
E 1 1 0 1 26 %mk=V
E 2 1 0 2 26 %mk=V
N 1 107 %sl=122
L 1 1 4 "1" %mk=V
E 0 7 1 2 30 %na=patient_in %mk=V %sl=121
N 2 107 %sl=123
L 2 1 4 "1" %mk=V
E 0 4 2 2 30 %na=doctor_out %mk=V %sl=122
} 1 4 4 0 1 2 3 %sl=102
E 0 1 1 1 9 %na=list_of_patients %mk=V %sl=104
E 0 2 1 2 9 %na=list_of_doctors %mk=V %sl=108
define doctors_office
% These routines model a doctor's office. There is no global clock, no
% global communication, and tasks have no a priori knowledge of events.
% People fall sick and go to the doctor's office to be cured. They wait
% in order of arrival to see the next available doctor. If no one is
% waiting, the doctors wait in order for patients to arrive.
%
% Due to the deterministic nature of Sisal, we can not queue patients in
% their order of arrival as this is nondeterministic. Instead, we modify
% the problem description to queue patients in the order they fall sick.
% Note the nurse still doesn't know when the next patient will arrive.
% Furthermore, Sisal can not express the problem's mutually recursive
% streams. We overcome this by encapsulating the three subtasks in an
% iterative loop, forcing the subtasks to execute in step. We believe
% this mode of execution is more restrictive than intended by the problem
% description.
type queue = array [integer];
type queue2 = array [array [integer] ];
global random (seed: integer returns real)
global next_seed (seed: integer returns integer)
% Take as input a seed and a queue of healthy persons. If the queue is
% empty or no one has fallen sick (the if and elseif clauses), return
% a ghost and the queue; else, choose a patient to become sick and re-
% turn his identity and the queue minus that patient.
function well_persons (seed: integer; patients: queue
returns queue, queue)
let
x := random(seed);
size := array_size(patients);
sick := floor(real(size) * x / 0.7) + 1
in
if size = 0 | x = 0.7 then
patients, array queue []
else
array_remh(patients[sick: patients[size]]),
array [1: patients[sick]]
end if
end let
end function % well_persons
% Take as input a queue of patients and a queue of doctors. If the queue
% of patients or the queue of doctors is empty (the if clause), return
% the inputs and an empty queue of patient-doctor records; else, remove
% the first patient and doctor from their respective queues, and return
% the queue of sick persons with everyone moved up one, the queue of
% doctors with everyone moved up one, and a queue of the patient-doctor
% identities.
function nurse(patients: queue; doctors: queue
returns queue, queue2, queue)
let
n_patients := array_size(patients);
n_doctors := array_size(doctors)
in
if (n_patients = 0) | (n_doctors = 0) then
patients, array queue2 [], doctors
else
array_setl(array_reml(patients), 1),
array [1: array [1: patients[1], doctors[1]]],
array_setl(array_reml(doctors), 1)
end if
end let
end function % nurse
% Take as input a seed and a queue of patient-doctor pairs. If the queue
% is empty or no one has been cured,return an empty queue of patients,
% doctors, and the queue of patient-doctor pairs; else, choose a patient-
% doctor pair, and return the patient's identity, the doctor's identity,
% the queue minus the chosen patient-doctor pair.
function examinations (seed: integer; in_exam: queue2
returns queue2, queue, queue)
let
x := random(seed);
size := array_limh(in_exam);
cured := floor(real(size) * x / 0.3) + 1
in
if size = 0 | x >= 0.3 then
in_exam, array queue [], array queue []
else
array_remh(in_exam[cured: in_exam[size]]),
array [1: in_exam[cured, 1]],
array [1: in_exam[cured, 2]]
end if
end let
end function % examinations
function doctors_office (list_of_patients, list_of_doctors: queue
returns stream[queue], stream[queue])
for initial
seed := 0;
still_well := list_of_patients;
patient_out := array queue [];
still_sick := array queue [];
patient_in := array queue [];
still_available := list_of_doctors;
doctor_out := array queue [];
still_examining := array queue2 [];
patient_doctor := array queue2 []
while true repeat
seed := next_seed(old seed);
still_well, patient_in :=
well_persons(seed, old still_well || old patient_out);
still_sick, patient_doctor, still_available :=
nurse(old still_sick || old patient_in,
old still_available || old doctor_out);
still_examining, patient_out, doctor_out :=
examinations(seed, old still_examining || old patient_doctor)
returns stream of patient_in
stream of doctor_out
end for
end function % doctors_office
T 1 1 0 %na=Boolean
T 2 1 1 %na=Character
T 3 1 2 %na=Double
T 4 1 3 %na=Integer
T 5 1 4 %na=Null
T 6 1 5 %na=Real
T 7 1 6 %na=WildBasic
T 8 10
T 9 0 4 %na=onedim
T 10 6 4 %na=istream
T 11 8 10 0
T 12 8 4 11
T 13 8 4 12
T 14 3 13 11
T 15 8 9 0
T 16 8 4 15
T 17 3 16 11
T 18 4 4
T 19 4 1
T 20 4 10
C$ C Faked IF1CHECK
C$ D Nodes are DFOrdered
C$ F Livermore Frontend Version1.8
G 14 "powers" %sl=15
E 1 1 0 1 10 %mk=V
{ Compound 1 4
G 0 %sl=18
E 4 1 0 4 10 %na=b_stream %mk=V %sl=21
E 2 1 0 5 10 %na=s_stream %mk=V %sl=20
E 1 1 0 6 4 %na=token %mk=V %sl=21
E 5 1 0 7 1 %mk=V
N 1 105 %sl=19
E 0 1 1 1 10 %na=in_stream %mk=V %sl=19
L 1 2 4 "1" %mk=V
N 2 112 %sl=20
E 0 1 2 1 10 %na=in_stream %mk=V %sl=20
N 3 152 %sl=21
E 1 1 3 1 4 %na=token %mk=V %sl=21
E 0 2 3 2 4 %na=prime %mk=V %sl=21
N 4 103 %sl=21
L 4 1 4 "1" %mk=V
E 3 1 4 2 4 %mk=V
N 5 132
E 1 1 5 1 4 %na=token %mk=V
E 0 3 5 2 4 %na=n %mk=V
G 0 %sl=22
E 1 1 0 1 1 %mk=V
N 1 131 %sl=22
E 0 6 1 1 4 %na=token %mk=V %sl=22
E 0 3 1 2 4 %na=n %mk=V %sl=22
G 0 %sl=23
E 5 3 0 4 10 %na=b_stream %mk=V %sl=39
E 5 2 0 5 10 %na=s_stream %mk=V %sl=38
E 5 1 0 6 4 %na=token %mk=V %sl=22
E 6 1 0 7 1 %mk=V
N 1 105 %sl=25
E 0 5 1 1 10 %na=old-s_stream %mk=V %sl=25
L 1 2 4 "1" %mk=V
N 2 105 %sl=26
E 0 4 2 1 10 %na=old-b_stream %mk=V %sl=26
L 2 2 4 "1" %mk=V
N 3 108 %sl=28
E 0 5 3 1 10 %na=old-s_stream %mk=V %sl=28
N 4 129
E 3 1 4 1 1 %mk=V
{ Compound 5 1
G 0
E 0 1 0 1 4 %mk=V
G 0 %sl=32
E 3 1 0 1 4 %mk=V
E 3 2 0 2 10 %mk=V
E 3 3 0 3 10 %mk=V
N 1 131 %sl=32
E 0 2 1 1 4 %na=b_token %mk=V %sl=32
E 0 6 1 2 4 %na=s_token %mk=V %sl=32
N 2 129
E 1 1 2 1 1 %mk=V
{ Compound 3 1
G 0
E 0 1 0 1 4 %mk=V
G 0 %sl=36
E 0 6 0 1 4 %na=s_token %mk=V %sl=39
E 1 1 0 2 10 %mk=V
E 3 1 0 3 10 %mk=V
N 1 112 %sl=38
E 0 3 1 1 10 %na=old-s_stream %mk=V %sl=38
N 2 152 %sl=39
E 0 6 2 1 4 %na=s_token %mk=V %sl=39
E 0 5 2 2 4 %na=prime %mk=V %sl=39
N 3 100 %sl=39
E 0 4 3 1 10 %na=old-b_stream %mk=V %sl=39
E 2 1 3 2 4 %mk=V
G 0 %sl=33
E 0 2 0 1 4 %na=b_token %mk=V %sl=35
E 0 3 0 2 10 %na=old-s_stream %mk=V %sl=34
E 3 1 0 3 10 %mk=V
N 1 112 %sl=35
E 0 4 1 1 10 %na=old-b_stream %mk=V %sl=35
N 2 152 %sl=35
E 0 2 2 1 4 %na=b_token %mk=V %sl=35
E 0 5 2 2 4 %na=prime %mk=V %sl=35
N 3 100 %sl=35
E 1 1 3 1 10 %mk=V
E 2 1 3 2 4 %mk=V
} 3 1 3 0 1 2 %sl=33
E 2 1 3 1 4 %mk=V
E 0 2 3 2 4 %na=b_token %mk=V %sl=33
E 0 3 3 3 10 %na=old-s_stream %mk=V %sl=34
E 0 4 3 4 10 %na=old-b_stream %mk=V %sl=35
E 0 5 3 5 4 %na=prime %mk=V %sl=35
E 0 6 3 6 4 %na=s_token %mk=V %sl=37
G 0 %sl=29
E 0 2 0 1 4 %na=b_token %mk=V %sl=31
E 0 3 0 2 10 %na=old-s_stream %mk=V %sl=30
E 3 1 0 3 10 %mk=V
N 1 112 %sl=31
E 0 4 1 1 10 %na=old-b_stream %mk=V %sl=31
N 2 152 %sl=31
E 0 2 2 1 4 %na=b_token %mk=V %sl=31
E 0 5 2 2 4 %na=prime %mk=V %sl=31
N 3 100 %sl=31
E 1 1 3 1 10 %mk=V
E 2 1 3 2 4 %mk=V
} 5 1 3 0 1 2 %sl=29
E 4 1 5 1 4 %mk=V
E 2 1 5 2 4 %na=b_token %mk=V %sl=29
E 0 5 5 3 10 %na=old-s_stream %mk=V %sl=30
E 0 4 5 4 10 %na=old-b_stream %mk=V %sl=31
E 0 2 5 5 4 %na=prime %mk=V %sl=31
E 1 1 5 6 4 %na=s_token %mk=V %sl=32
N 6 132
E 5 1 6 1 4 %na=token %mk=V
E 0 3 6 2 4 %na=n %mk=V
G 0 %sl=42
E 2 1 0 1 10 %mk=V
N 2 107 %sl=43
L 2 1 4 "1" %mk=V
E 0 6 2 2 18 %na=token %mk=V %sl=42
E 0 7 2 3 19 %mk=V
} 1 4 4 0 1 2 3 %sl=18
E 0 3 1 1 10 %na=in_stream %mk=V %sl=19
E 0 2 1 2 4 %na=prime %mk=V %sl=21
E 0 1 1 3 4 %na=n %mk=V %sl=22
X 17 "hamming" %sl=47
E 1 1 0 1 10 %mk=V
{ Compound 1 4
G 0 %sl=50
L 0 3 4 "0" %na=i %mk=V %sl=51
E 1 1 0 4 10 %na=s_stream %mk=V %sl=52
N 1 103 %sl=52
L 1 1 4 "1" %mk=V
L 1 2 4 "1" %mk=V
G 0 %sl=53
E 2 1 0 1 1 %mk=V
N 1 116 %sl=53
E 0 1 1 1 9 %na=primes %mk=V %sl=53
N 2 131 %sl=53
E 0 3 2 1 4 %na=i %mk=V %sl=53
E 1 1 2 2 4 %mk=V
G 0 %sl=54
E 1 1 0 3 4 %na=i %mk=V %sl=55
E 3 1 0 4 10 %na=s_stream %mk=V %sl=55
N 1 141 %sl=54
E 0 3 1 1 4 %na=old-i %mk=V %sl=54
L 1 2 4 "1" %mk=V
N 2 105 %sl=55
E 0 1 2 1 9 %na=primes %mk=V %sl=55
E 1 1 2 2 4 %na=i %mk=V %sl=55
N 3 120 %sl=55
L 3 1 14 "powers" %mk=V
E 0 2 3 2 4 %na=n %mk=V %sl=55
E 2 1 3 3 4 %mk=V
E 0 4 3 4 10 %na=old-s_stream %mk=V %sl=55
G 0 %sl=56
E 1 1 0 1 10 %mk=V
N 1 127 %sl=57
E 0 4 1 1 20 %na=s_stream %mk=V %sl=56
} 1 4 4 0 1 2 3 %sl=50
E 0 2 1 1 9 %na=primes %mk=V %sl=53
E 0 1 1 2 4 %na=n %mk=V %sl=55
define hamming
type OneDim = array[integer];
type Istream = stream[integer];
% Take as input an integer, n, and a set of primes, A, B, C, ... , and
% return a stream of all integers less than or equal to n in order and
% without duplicates of the form, (A ** i) * (B ** j) * (C ** k) * ...
% The main routine calls powers for each prime. powers manipulates two
% two streams of tokens: s_stream, the stream of tokens generated by
% the previous call to powers; and b_stream, the stream of tokens gen-
% erated by the present call. By selecting the smaller of the heads of
% b_stream and s_stream, the tokens are output in order.
function powers(n, prime: integer; in_stream: Istream
returns Istream)
for initial
token := stream_first(in_stream);
s_stream := stream_rest(in_stream);
b_stream := stream [token * prime]
while token < n repeat
token, s_stream, b_stream :=
let