Live data from Hacker News

The Array Cast – A podcast about the array programming languages

arraycast.com

71–80 of 141 posts

Re: The Array Cast – A podcast about the array programming languages

#71
post #58

Earlier quoted context omitted.

I am going to tell you something fantastic, but first, I want to explain some things about this: us:{$[#i:&{(y~*K)&"*"~*x}':x;@[x;i;:[;,"_"]];x]} The first is that there's a typo in what bidirectional wrote. The above is correct. The second, is what it is. Once I have explained that, I can tell you the fantastic thing. k syntax is very simple. There's just a few forms you need to be aware of: f x which applies x to f…

Is the open source version (Kona) any good? Or do we have to go proprietary to try this out?

I had much fun learning the klong language: https://t3x.org/klong/

I even bought the well written book, which was a pleasure to read.

Re: The Array Cast – A podcast about the array programming languages

#72
post #57

Earlier quoted context omitted.

What I can't understand is what would J do if I tell it to sum these two arrays: 1 2 3 4 5 6 7 8 I.e. 5 elements and 3 elements

1 2 3 + 4 5 6 7 |length error | 1 2 3 +4 5 6 7 In general - depends on the operation. Sometimes the verb checks that both operands have the same rank and dimensions, sometimes the shorter/smaller side gets applied column-wise (or cell-wise/page-wise): (2 2 $ 1 2 3 4) NB. $ means "reshape" 1 2 3 4 (2 2 $ 1 2 3 4) + 1 2 2 3 5 6 Sometimes the shorter side is repeated as much as needed to get the correct length, and some…

I don't think $ is of worthy note here. It's literally a builtin for cycling data, that's what it does.

All simple arithmetic follows leading axis agreement[1] (so erroring on mismatched length, and mapping over cells for high rank). Don't know much about other builtins, but, unless J does some weird stuff I don't know about (I don't know much of J), it shouldn't be too illogical.

[1] https://aplwiki.com/wiki/Leading_axis_agreement

Re: The Array Cast – A podcast about the array programming languages

#74
post #68

Earlier quoted context omitted.

1 2 3 + 4 5 6 7 |length error | 1 2 3 +4 5 6 7 In general - depends on the operation. Sometimes the verb checks that both operands have the same rank and dimensions, sometimes the shorter/smaller side gets applied column-wise (or cell-wise/page-wise): (2 2 $ 1 2 3 4) NB. $ means "reshape" 1 2 3 4 (2 2 $ 1 2 3 4) + 1 2 2 3 5 6 Sometimes the shorter side is repeated as much as needed to get the correct length, and some…

Gotta say, "depends on the operation" was the most unfortunate possible answer to my question, alas :-) Maybe one day we'll figure out how to make a consistent array language ;-)

Give this a try: https://t3x.org/klong/klong-ref.txt.html

Re: The Array Cast – A podcast about the array programming languages

#75
post #42

Earlier quoted context omitted.

it's extremely readable when used to it, though. I use J for exploratory data analysis. It's really, really good at that kind of thing.

I've lost count of the number of times I've heard some theoretical mathematician say that about impenetrable gibberish.

"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something."

Dismissing what you don't understand because it is unfamiliar is the essence of a shallow dismissal, no? And you did it twice in this thread. The first was a blessing in disguise because of geocar's excellent reply, but now you're just repeating it, with added name-calling. Please don't do that here.

https://news.ycombinator.com/newsguidelines.html

Re: The Array Cast – A podcast about the array programming languages

#76
post #64

Earlier quoted context omitted.

Unfortunately, I have no idea about the implementation and what optimizations are done in J or APL for which operations :( I know that there are hardcoded "fast path" expressions (particular combinations of operations) which have much better performance than more general expressions doing the same thing, so it might be that the optimization happens at that level. OTOH, your example is very verbose when compared to J'…

even less verbose: (>: i. 3 3) * 10

...or

10 * >: i. 3 3

FWIW

Re: The Array Cast – A podcast about the array programming languages

#77
post #63
post #16

Earlier quoted context omitted.

Is an array language a language where you only have arrays? That honestly sounds a bit odd.

Mostly yes. Numbers (and character) are implemented as arrays with 0 dimensions. Text would be an array of characters with 1 dimension (the number of characters), and generally speaking the dimension of an array is a one dimensional list of non-negative integers. Many array languages also include an array type which is approximately the same as a C pointer to an array, with a bit of jargon thrown in to distinguish a…

From the J docs: https://www.jsoftware.com/help/dictionary/dx005.htm

  nub=: (i.@# = i.~) # ]
     5!:2 
... so J functions have an array representation, at least.

Re: The Array Cast – A podcast about the array programming languages

#78
post #68

Earlier quoted context omitted.

1 2 3 + 4 5 6 7 |length error | 1 2 3 +4 5 6 7 In general - depends on the operation. Sometimes the verb checks that both operands have the same rank and dimensions, sometimes the shorter/smaller side gets applied column-wise (or cell-wise/page-wise): (2 2 $ 1 2 3 4) NB. $ means "reshape" 1 2 3 4 (2 2 $ 1 2 3 4) + 1 2 2 3 5 6 Sometimes the shorter side is repeated as much as needed to get the correct length, and some…

Gotta say, "depends on the operation" was the most unfortunate possible answer to my question, alas :-) Maybe one day we'll figure out how to make a consistent array language ;-)

Well, for what it's worth - and as mentioned by a sibling poster - most verbs, and certainly all arithmetic operators, obey a few simple rules for determining which behavior you'll get. I should have noted this, before I started whining about all the other verbs, which don't :D

Re: The Array Cast – A podcast about the array programming languages

#79
post #58

Earlier quoted context omitted.

What the actual f? It's like someone threw up the noise that modems make during initial connection onto an electric typewriter from the 1960s, and then explained their intention using quotes from a Lovecraft novel.

I am going to tell you something fantastic, but first, I want to explain some things about this: us:{$[#i:&{(y~*K)&"*"~*x}':x;@[x;i;:[;,"_"]];x]} The first is that there's a typo in what bidirectional wrote. The above is correct. The second, is what it is. Once I have explained that, I can tell you the fantastic thing. k syntax is very simple. There's just a few forms you need to be aware of: f x which applies x to f…

TXR Lisp:

  1> (defun rewrite (fun list)
      (build
        (while* list
          (let ((nlist [fun list]))
            (if (eq list nlist)
              (if list (add (pop list)))
              (set list nlist))))))
  rewrite
  2> (defmacro rewrite-case (sym list . cases)
      ^(rewrite (lambda (,sym)
                  (match-case ,sym
                    ,*cases))
                ,list))
  rewrite-case
  3> (rewrite-case x '(foo bar * select * fox select * bravo)
       ((select * . @rest) ^(select _ . ,rest))
       (@else else))
   (foo bar * select _ fox select _ bravo)
rewrite-case and rewrite appear in the TXR Lisp internals; they are used in the compiler for scanning instruction sequences for patterns and rewriting them.

E.g. a function early-peephole looks for one particular four instruction pattern (six items, when the labels are included). Rewriting it to a different form helps it disappear later on.

  (defun early-peephole (code)
    (rewrite-case insns code
      (((mov (t @t1) (d @d1))
        (jmp @lab2)
        @(symbolp @lab1)
        (mov (t @t1) (t 0))
        @lab2
        (ifq (t @t1) (t 0) @lab3)
        . @rest)
      ^((mov (t ,t1) (d ,d1))
        (jmp ,lab3)
        ,lab1
        (mov (t ,t1) (t 0))
        ,lab2
        ,*rest))
      (@else else)))
This is much more general and powerful than a hack which just looks at successive pairs for an ad-hoc match. rewrite-case can have multiple clauses, of different lengths, and arbitrary matching complexity.

Re: The Array Cast – A podcast about the array programming languages

#80
post #72

Earlier quoted context omitted.

1 2 3 + 4 5 6 7 |length error | 1 2 3 +4 5 6 7 In general - depends on the operation. Sometimes the verb checks that both operands have the same rank and dimensions, sometimes the shorter/smaller side gets applied column-wise (or cell-wise/page-wise): (2 2 $ 1 2 3 4) NB. $ means "reshape" 1 2 3 4 (2 2 $ 1 2 3 4) + 1 2 2 3 5 6 Sometimes the shorter side is repeated as much as needed to get the correct length, and some…

I don't think $ is of worthy note here. It's literally a builtin for cycling data, that's what it does. All simple arithmetic follows leading axis agreement[1] (so erroring on mismatched length, and mapping over cells for high rank). Don't know much about other builtins, but, unless J does some weird stuff I don't know about (I don't know much of J), it shouldn't be too illogical. [1] https://aplwiki.com/wiki/Leading…

> I don't think $

You're right, although cycling instead of erroring out was surprising to me. Another verb I had trouble with is roll/deal: https://code.jsoftware.com/wiki/Vocabulary/query

> it shouldn't be too illogical.

I'm not saying it's illogical. I'm pretty sure there are good reasons behind the design of each word, especially since there are so few. As I mentioned, I suspect it's just a matter of me not getting enough exposure to the various use-cases of many standard words.

Post reply on HN