blob: 4c7f0a4a63623b25d1c20f4a6ffe9c5973ac14cc (
plain)
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
|
# Define a constructor for making a 2-tuple (a, b)
new-pair a b fn = fn a b;
# Define selector functions for picking out an element from the 2-tuple
pair-first p = p true;
pair-second p = p false;
# Test them out
my-pair = new-pair 1 2;
pair-first my-pair;
pair-second my-pair;
# Define a constructor for making a 3-tuple (a, b, c)
new-triple a b c fn = fn a b c;
# Define selector functions for picking out an element from the 3-tuple
select1 a b c = a;
select2 a b c = b;
select3 a b c = c;
triple-first t = t select1;
triple-second t = t select2;
triple-third t = t select3;
# Test them out
my-triple = new-triple "a" "b" "c";
triple-first my-triple;
triple-second my-triple;
triple-third my-triple;
|