<commit_before># lambda
Use symbol λ in JavaScript to write succient functions.
# Explanation
The first version of the function was this:
~~~
var λ = function(expr) {
	return new Function('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'return ' + expr)
}
~~~
This allows writing functions like this:
~~~
var add = λ('a + b')

add(8, 9) // returns 17
~~~
The Function constructor takes argument names until the last parameter, which is the function body. This causes the arguments to bind to instances of a, b, c, etc.

After adding some more complex features, I was able to write functions like this:

~~~
var keysAndValues = λ([], [], λ.kv(a, A.push(k), B.push(v)), [A, B])
~~~

This is a function which returns a pair of parallel arrays, one of the keys and one of the values of an object. It also assumes placeholders are applied to the local scope, which explain where the a, A, b, B, k, and v variables are coming from. Let's break this down:
~~~
eval(λ.localPlaceholders()) // creates placeholders in current scope

A.push(k) // returns 'A.push(k)'
~~~
A is a placeholder, a with toString() overloaded to return 'A', and the member 'push' returning 'A.push(...)' (... is whatever parameters are passed to it). Calling a placeholder has this effect:
~~~
A(a, b) // returns 'A(a, b)'
~~~
- Each parameter to λ is a line in the resulting function.
- Lines that do not begin with some control statement (for, if, return, etc) are treated as variable initializations.
- The first variable is named A for you, the second named B, and so on.
- If the last line of the function does not begin with a control statement, it is returned.
- λ.kv is one of 6 looping functions. They loop over a collection (either an array or an object, or either in KV's case), expanding into inlined for-loops.
- [] and [A, B] are detected as arrays, and arrays are converted to strings such as '[]' and '[A, B]'.
<commit_msg>added break down<commit_after># lambda
Use symbol λ in JavaScript to write succient functions.
# Explanation
The first version of the function was this:
~~~
var λ = function(expr) {
	return new Function('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'return ' + expr)
}
~~~
This allows writing functions like this:
~~~
var add = λ('a + b')

add(8, 9) // returns 17
~~~
The Function constructor takes argument names until the last parameter, which is the function body. This causes the arguments to bind to instances of a, b, c, etc.

After adding some more complex features, I was able to write functions like this:

~~~
var keysAndValues = λ([], [], λ.kv(a, A.push(k), B.push(v)), [A, B])
~~~

This is a function which returns a pair of parallel arrays, one of the keys and one of the values of an object. It also assumes placeholders are applied to the local scope, which explain where the a, A, b, B, k, and v variables are coming from. Let's break this down:
~~~
eval(λ.localPlaceholders()) // creates placeholders in current scope

A.push(k) // returns 'A.push(k)'
~~~
A is a placeholder, a with toString() overloaded to return 'A', and the member 'push' returning 'A.push(...)' (... is whatever parameters are passed to it). Calling a placeholder has this effect:
~~~
A(a, b) // returns 'A(a, b)'
~~~
Break down:
- Each parameter to λ is a line in the resulting function.
- Lines that do not begin with some control statement (for, if, return, etc) are treated as variable initializations.
- The first variable is named A for you, the second named B, and so on.
- If the last line of the function does not begin with a control statement, it is returned.
- λ.kv is one of 6 looping functions. They loop over a collection (either an array or an object, or either in KV's case), expanding into inlined for-loops.
- [] and [A, B] are detected as arrays, and arrays are converted to strings such as '[]' and '[A, B]'.

{'fraction_non_alphanumeric': 0.1152533473352586, 'fraction_numerical': 0.002625360987135731, 'mean_word_length': 3.954486345903771, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '153580', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1088, 'n_words': 606}