238 karma · joined November 14, 2019
— Can you teach a computer to write poetry?
— If you can teach it--yes, there's nothing easier. One of the things is that you could do, for example, you could simply give it a collection of poems or prose or whatever you have, and then provide a program which selects pieces from these, either individual words, individual phrases, individual passages, and so on, and merges them together according to some criterion, which you would then write into the program, and also with a certain element of chance. Usually, you know, you'd say, "Well, you want to pick this sometimes, that sometimes." Yes, you can write it, but you raise the question, what would be the point?
foo(bar(baz(42)))
and then remove the superfluous parens foo bar baz 42
The expression is evaluated from right to left.Now, let's make two of the functions into object members:
A.foo(bar(B.baz(42)))
Remove the parens, extracting the methods from their objects, instead feeding each object as a left argument to its former member function: A foo bar B baz 42
This is normal APL-style call syntax; right-to-left if you want. x f[k] y
This one is universal among traditional APLs (though some modern APLs, including J, remove it). However, it is traditionally only used for a concept of application along an axis of APL's multidimentional arrays, and only for a strictly limited set of built-in "operators". That said, GNU APL and NARS2000 both allow it on user-defined functions (which have infix syntax, just like "operators"). x n.f y
This is infix application of the function f from the namespace n, so n must have namespace value, but it is still a proper argument because n isn't just an identifier, but can also be an expression: x (expression).f y
In fact, the expression can be an entire (multidimentional!) array of namespaces: x (namespace1 namespace2).f y
is equivalent to (x[1] namespace1.f y[1])(x[2] namespace2.f y[2])
Furthermore, f can be a built-in "operator" which appears to exist in every namespace, but which also takes the current namespace into consideration. For example, x⍳y is the position of y in x and if io0 is a namespace wherein indexing is 0-based and io1 is a namespace wherein indexing is 1-based, we can write: 'AX' 'BX' (ns0 ns1).⍳ 'X'
and get the result 1 2 because X is at position 1 in AX with 0-based indexing but at position 2 of BX with 1-based indexing. (I'm not saying you should write code like this, but you could.) if a < b → c := true
□ a ≥ b → c := false
fi
To an APL dfn with "guards": c ← {
a < b : true
a ≥ b : false
}
As in GCL, if none of the guards hold true, the dfn (braces) will terminate without return value, and thus the code will abort with an error.- https://www.youtube.com/watch?v=w1VMeSzJLyE&list=PLYKQVqyrAE...
- https://www.youtube.com/watch?v=_jBQ53cRi0s&list=PLYKQVqyrAE...
- https://www.youtube.com/watch?v=a65K-0jaWc4&list=PLYKQVqyrAE...
See https://en.wikipedia.org/wiki/APL_(programming_language)#/me...
<form id=theme>
<label for=theme-l>light</label><input id=theme-l type=radio name=theme value=l>
<input id=theme-d type=radio name=theme value=d checked><label for=theme-d>dark</label>
</form>
<style>
input:checked{position:relative;z-index:1}
input+input{margin-left:-1em}
</style>
It is ugly, hard to style right, doesn't have toggle semantics, and needs strange code like theme.theme.value to get the value.I'd much rather write:
<select type=switch id=theme>
<option value=l>light</option>
<option value=d selected>dark</option>
</select>
And it'd be an actual switch with one label on each side and I'd get the value with theme.valueMake a new element or input type that makes it easy to do switches right, with two labels.
dot←+.×
but why give it a name when spelling it out is as short as the shortest reasonable name for it (and then you might need to put spaces around the name).Enter 1+2 where the cursor is below the copyright notice.
Now click or use arrow keys to navigate up and change the 2 to a 4 and hit Enter again.