Moving the thread over to chat
Thanks Dan. Drawing a distinction is helpful.
I internalized the difference between a.r.s and gerunds using an
analogy from lisp
a.r.s. would be a symbol and a gerund would be a list of symbols
For example, in elisp:
[note: I included the second lambda form of add4l as another example
of an atomic representation. That variable can be passed around more
easily than the defun which needs to be quoted. Many interpreters
(including elisp) will output the value of the lambda as well but
won't do it on the defun. Other lisps, picolisp for example, treats
them the same. The lambda can also be manipulated through code.]
#+begin_src elisp
(defun add2 (x) (+ 2 x))
(setq add4l (lambda (x) (+ 4 x)))
(setq gerund (list 'add2 add4l 'sqrt 'log))
(defun applyall (ars) (mapcar (lambda (x) (funcall ars x)) '(1 2 3)))
(mapcar 'applyall gerund)
#+end_src
#+RESULTS:
| 3 | 4 | 5 |
| 5 | 6 | 7 |
| 1.0 | 1.4142135623730951 | 1.7320508075688772 |
| 0.0 | 0.6931471805599453 | 1.0986122886681098 |
Which seems similar conceptually to
add2=: 2 + [
add4=: 4 + [
G=:(add2 ` add4 ` %: ` ^. `:0)
G 1 2 3
3 4 5
5 6 7
1 1.41421 1.73205
0 0.693147 1.09861
As mentioned the paper mentioned above, since a gerund is a list, it
can be manipulated / selected from:
3 {:: G 1 2 3
0 0.693147 1.09861
Same with a list of symbols:
#+begin_src elisp
(mapcar (nth 3 gerund) '(1 2 3))
#+end_src
#+RESULTS:
| 0.0 | 0.6931471805599453 | 1.0986122886681098 |
Is this the proper analogy?
I didn't clearly understand your final point...
Dan wrote:
> More explicitly: Java has a buttload of built-in array functions, because
> the market demands them. But, as a language, Java hasn't yet recognized that
> manipulation of collections, as opposed to values, is a fundamental activity
> in computer programming. Hence, it provides value-semantics as fundamental,
> first-class members of its specification (classes) and structure-semantics
> as an afterthought - second-class citizens (functions on those classes).
I've read that Java 8 introduced lambdas and a Stream class that is
defined as "A sequence of elements supporting sequential and parallel
aggregate operations"
http://download.java.net/jdk8/docs/api/java/util/stream/Stream.html
I'm not a Java programmer - I write more c# which has had similar
operations since 2007. I don't quite understand the distinction you
make between first-class members (classes) and second-class citizens
(functions).
I am guessing that at least one of the differences lies in J's verb
rank and how it implicitly creates loops instead of having to
explicitly call create loops or call mapping functions.
Is that the key difference?
On Mon, Nov 4, 2013 at 9:03 PM, Dan Bron <[email protected]> wrote:
> I wrote:
>> The official documentation is light on atomic
>> representations (a.r.s), and aside from the
>> overview at [1] (referenced earlier), I believe
>> they're supposed to be "self-explanatory".
>
> Joe Bogner responded:
>> The NuVoc entry on ` also covers it well:
>> http://www.jsoftware.com/jwiki/Vocabulary/backtick
>
> I think it's worth drawing a distinction, here.
>
> Atomic representations (a.r.s) and gerunds are intimately related, but not
> identical. The documentation for 5!:1 covers the former, and the NuVoc
> entry for tie discusses the latter.
>
> A gerund is an array of a.r.s. That is, the atoms of a gerund are atomic
> representations. Note that this definition includes a single, solitary, a.r.
> under "gerund" (just as "4" is still an "array" - because all nouns in J are
> arrays, singleton or compound).
>
> So, the real difference between a.r.s and gerunds is one of focus. When we
> say "atomic representation", we're focusing on the _value_ of the atoms:
> what a specific a.r. represents, how we might change it, and what it could
> do if we "woke it up", all without reference to the larger context. In
> contrast, when we speak of "gerunds", we're focusing on the _structure_ of
> the array, without reference to the specific values.
>
> So, for example, we often like to talk about how @. is a functional analog
> to case statements, because it takes a list of potential functions to call
> -- a gerund -- and evokes one based on characteristics of its input. We
> discuss this in the abstract, as we discuss case statements in the abstract,
> without reference to any specific list of functions or input.
>
> In contrast, the majority of this thread has been focused on the
> manipulation of a.r.s to produce different, related, a.r.s. For example,
> when we described how to extract the a.r. of y from the of a.r. y"_ by
> applying {.@>@:{: to the structure '"';y;<'0';_ .
>
> This effortless, seamless transition of focus from frame to contents and
> contents to frame is one of the hallmarks of J, and one of the joys of
> working with the language. In fact, I believe the APLs' true gift to the
> world -- and their most likely legacy, their impact on computer science --
> is precisely that they endow the position of data with as much significance
> as its value. I really don't think it's a stretch to draw an analogy with
> the advancements in mathematics permitted by the improvement of positional
> notation over the Roman numeral system.
>
> So, just as we might talk about the number 12345 or the digits 1 2 3 4 5, we
> might talk about the gerund +`-`*`%`^ and the verbs + - * % ^ . For
> example, the 3rd digit of 12345 is 3 and the 3rd verb of +`-`*`%`^ is * .
> The magnitude of 12345 is 5 (# 1 2 3 4 5) and the length of +`-`*`%`^ is 5
> (# +`-`*`%`^). We can add 1 to the number 12345 (12346) or the digits 1 2 3
> 4 5 (23456) or a colon to the a.r.s + - * % ^ (+:`-:`*:`%:`^:) or the gerund
> +`-`*`%`^ (+`-`*`%`^`(<':')). Etcetera.
>
> It's actually a fun exercise to look at the Vocabulary and identify which
> verbs are structure- vs value-oriented*. Unsurprisingly for an array
> language, there's a good mix of both. In contrast, such a balance would be
> very surprising for a scalar-oriented language. Though we can begin to see
> the dawn breaking: e.g. the Java SDK defines a large number of core classes,
> which are analogous to value-oriented verbs in J, but if you compare the
> number og methods each defines, you might notice some statistical
> aberrations in the Collection category.
>
> More explicitly: Java has a buttload of built-in array functions, because
> the market demands them. But, as a language, Java hasn't yet recognized that
> manipulation of collections, as opposed to values, is a fundamental activity
> in computer programming. Hence, it provides value-semantics as fundamental,
> first-class members of its specification (classes) and structure-semantics
> as an afterthought - second-class citizens (functions on those classes).
>
> The time is ripe for another civil rights movement. Arrays are not
> second-class citizens. Arrays of the world (oh, the irony) ... unite!
>
> -Dan
>
>
> * Hint: look at verb rank. By definition, rank-zero (scalar) verbs are
> value-focused, because they can't even *see* arrays, only values. In
> contrast, verbs with unbound (infinite) rank can see values, but generally
> don't care to look at them. For example, * - * % are rank 0, whereas # $ <
> {. are rank _ , and %. is rank 2 (a little bit of both).
>
> PS: For an example of the difference between atomic representations and
> gerunds, one must only look to the paper that introduced both. Note that
> "Gerunds and Representations" only spends a single paragraph defining what
> an a.r. is
>
> The atomic (boxed, canonical) representation
> of an object uniquely represents it ...
>
> .. and then spends the balance of the paper, 7+ pages, describing the use of
> _arrays_ of them:
>
> An array so constructed, a noun derived from
> verbs, is a gerund. Since gerunds are arrays, they
> can be manipulated by verbs. In the jargon of
> computer scientists, verbs in J are thereby
> "first class" objects.
>
> But that paper is from is from 1991, so if you're looking for something a
> little more recent, there was discussion of the difference between gerunds
> and a.r.s, in the "verb display" thread last year (hey, I said /more/
> recent):
>
> http://www.jsoftware.com/pipermail/programming/2012-February/027253.html
>
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm