# OK so lets take this apart again vs http dumpz org 11719 here the orig

 ``` 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``` ```# OK, so lets take this apart again vs. http://dumpz.org/11719/ :) # here's the original: (A:((L:range(10)) each()), B:(L each())) collect(A + B = 10) # I'll simplify the thing by removing unnecessary priority grouping and some formating... (A: (L: range(10)) each(), B: L each()) collect(A + B = 10) # now lets take it apart... # # first for some general info # - anything in the language is a pattern. be it specific values, resolvable or unresolvable expressions or # conflicts (similar in some cases to exceptions). # - undefined identifiers are patterns that match anything (ANY). # - semicolon is a binding operation; binding an identifier to a pattern. # # # this will tell us that we are defining three names in the above code: A, L and B in order of definition. L # being a list containing a sequence of numbers from 0 to 9. # # # now to the next part: the each([PATTERN]) view. # each is essentially a way to look at all the elements of the container at the same time, in parallel. every # operation on an each will be applied to each element of the container and will return a new each containing # results. thus, A and B are two *different* each objects to the same container. # # NOTE: if pattern is not given, it is considered ANY. thus, the view -- each in this case -- will "see" all the # elements of the container. # # # so, the part up to the collect method will create a pattern that matches (contains) each element of the # Descartes square of L. # # # the last element of the puzzle: the collect([PATTERN]) method. # collect is a symmetric method to each. it creates a list of all the elements from an each view that match # the pattern. as with each if a pattern is not given it is considered ANY and all the elements are collected. # so the following is true: (X: set(range(10))) each() collect() == X # NOTE: we used set as the order after using each may be lost -- each objects are processed in parallel -- and # list comparison would fail most of the time. # # now for the pattern, I think that by now it is obvious, the values of A and B are all known, so collect will # only return pairs, the sum of which is 10 -- we use assignment rather than comparison because the former may # return a non-deterministic bool value while the later is a fact. # # as to your syntax suggestions, some things are logical but not all, I selected this particular example to # minimize exposure to and questions raised by foreign syntax. the only spot that looks different in the original # is the range constructor. so here is the full current syntactic version for this example: (A: (L: 0 ~ 9) each(), B: L each()) collect(A + B = 10) # # I am considering an operator instead of such methods as each and collect but this is not a priority IMHO :) # # now, how does this explanation sound? ```