647 karma · joined July 29, 2013
Interfaces: same API, different source code. Generics: different APIs, same source code.
This is why Go needs to have generics.
d:{_sqrt+/(y-x)^2}
ls: 2 10 # 20 _draw 0 // a list of 10 random points
+/d':ls // total length
Now if x, y above are vectors of points (as opposed to vectors of pairs), and if points have their own - verb, total length becomes "+/{y-x}':ls". But to define such a - for point, you'd need conversion verbs (or enclose/disclose). compositeSrc:{x} // output first arg
compositeDst:{y} // output second arg
compositeInvert:{+(1-x[;0];1-x[;1];1-x[;2];x[;3])}
// take a column, invert r, g, b columns and transpose
where x[i;0 1 2 3] == ith (r,g,b,a) of x. No need for "∀ (A, B) >>". This is implicit as k/APL work on whole collections. Basic operations are already overloaded. There would need to be a way to define tuples. "x[i;2]" to refer to ith blue value is a bit cryptic. You can define verb "blue x[i]" to do the same but may be some language syntax would help. I can't grasp enough of Nile through the examples I've seen so far but seems doable.It would've been good to see specific criticism instead of being just like classic APL.
I think many of APL/k/j verbs/adverbs can be generalized to working on streams (dataflow programming). Perhaps Dan Amelang's very interesting work on "2.5D" graphics can be cast into such an extended version....
(+/*)\:
is matrix multiplication. The following computes the transitive closure of a binary relation (represented as a boolean square matrix): {x|x(|/&)\:x}
Its core has a similar "shape" as matrix multiplication: (|/&)\:
So in a sense variable names don't matter all that much! To grok this code you have to stop thinking in terms of item at a time operations and start thinking of operations over collection of items. If you know how to write unix shell pipelines you are already somewhat familiar with this paradigm except that a shell doesn't provide most of the more useful features of array languages! tail +2It so happens that some Indians were brought over as indentured laborers by the British to various parts of their empire which resulted in the development of a large Indian diaspora: https://en.m.wikipedia.org/wiki/Indentured_servitude#Indian_...
But that’s old news!
https://www.washingtonpost.com/science/2019/01/17/experts-wa...
STRUCT (INT x, y) z = (1, 2)
Here z is a const struct. If you wanted a variable, you'd have to say STRUCT (INT x, y) z;
z := (1, 2)
or equivalently REF STRUCT (INT x, y) z = LOC STRUCT (INT x, y) := (1, 2)
Basically a variable has a REF mode.Surely you jest.
An April, 2016 academic study of bit.ly links shared on Twitter to BBC, CNN, Fox News, New York Times and Huffington Post articles found that 59 percent of the links were never clicked. And another study of push-through news alerts to mobile phones found that “People click on the alert about half the time.”
Source: https://honestreporting.com/tag/misleading-headlines/
What this means is most people only read the headline and not even the first line.
There are indeed lots of parallels between the two men.
(define (make-counter)
(let ((n 0)) (lambda () (set! n (+ n 1)) n)))
is guaranteed to work in any context where make-counter is called. Same in Go; though the syntax is a bit unwieldy due to having to specify types: func makeCounter() (func () int)) {
n := 0
return func () int { n++; return n }
}
Google's Go compiler is smart enough to allocate only the captured variable (n in this case) for such returned functions on the heap. There should be no failures.IIRC some algol-68 compiler did remove the restriction and allowed such full closures.