Source range 10 each each collect 10 Semicolons for object definitions

 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
; Source.
(A:((L:range(10)) each()) , B:(L each())) collect(A + B = 10)
; Semicolons for object definitions? Good. This reminds plain English: semicolons
; should be inserted before explanations, like in this sentence.
; But, in both English and Russian semicolons are often followed by whitespaces.
(A: ((L: range(10)) each()) , B: (L each())) collect(A + B = 10)
; Okay. Why not
L: range(10), A: (L each()) , B: (L each()), collect(A + B = 10)
; So now we really see that A and B are effectively the same thing.
; Next. each() selects anything from L at once. Why then "each"?
L: range(10), A: (L any()) , B: (L any()), collect(A + B = 10)
; Or maybe
L: range(10), A: any_from(L), B: any_from(L), collect(A + B = 10)
; Poor little method collect(). It does too much: pattern-matching, list conversion...
; Oh.
L: range(10), A: any_from(L), B: any_from(L), C: select(A + B = 10), flatten(C)
; Or
L: range(10), A: any_from(L), B: any_from(L), C: selection(A + B = 10), flatten(C)
; There remains only one problem. select() or collect()... what? "A + B = 10"?!
; How to "collect" an equality?
; Let me introduce you a "such ... that" operator. Let's call it "|".
; Wait... Gods... this reminds me lambdas. I'm sorry.
L: range(10), C: selection(A: any_from(L), B: any_from(L) | A + B = 10), flatten(C)
; To show you why it is important, let me show you an example.
; Suppose I'm to take only that nodes of L that make 10 with any node of M.
collect(L + M = 10) ; Nope, it will select nodes from both L and M
collect(L = 10 - M) ; Hey, mathematically it is the same thing!
collect(L + M = 10 && L) ; Unreadable.
; But Now! This looks almost obvious even in one operation!
flatten(selection(A: any_from(range(10)), B: any_from(range(10)) | A + B = 10))
; Almost jokingly. And one new method: the_same()!
; (I didn't invent it, I've just restyled an "!!" operation from UNIX shell)
flatten(selection(A: any_from(range(10)), B: the_same() | A + B = 10))
; Do you agree?