Live data from Hacker News

The Array Cast – A podcast about the array programming languages

arraycast.com

81–90 of 141 posts

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

#81
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?

ngn-k is a different dialect from Kona, but actively-maintained and open source: https://codeberg.org/ngn/k

oK (which is also k6) can be tried here: http://johnearnest.github.io/ok/index.html

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

#82
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…

Let's do this using the same approach, "find indices and assign over them in a copy of the sequence":

  This is the TXR Lisp interactive listener of TXR 259.
  Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
  Do not operate heavy equipment or motor vehicles while using TXR.
  1> (defun subst-select-* (list)
        (let ((indices (where (op starts-with '(select *))
                              (cons nil (conses list)))))
          (if indices
            (let ((list (copy list)))
              (set [list indices] (repeat '(_)))
              list)
            list)))
  subst-select-*
  2> (subst-select-* '(foo bar * select * fox select * bravo))
  (foo bar * select _ fox select _ bravo)
(conses list) gives us a list of the list's conses: e.g in (1 2 3) the conses are (1 2 3), (2 3) and (3), so the list of them is ((1 2 3) (2 3) (3)).

where applies a function to a sequence, and returns the 0-based indices of where the function yields true.

(op starts-with '(select *)) yields a lambda which tests whether its argument starts with (select *). No brainer.

If we naively applied that to the conses, we would get thew rong indices: the indices of the select symbols, not of the asterisks.

The workaround for that is (cons nil (conses list)): we cons an extra dummy nil element to shift the positions, and process the resulting list.

Once we have the indices list, if it isn't empty, we copy the original input, and assign underscore symbols into the indicated positions. To do that we generate an infinite lazy list of underscores; the assignment takes elements from this list and puts them into the specified index positions.

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

#83
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…

> I have to look up range/xrange and len and memorise

All you're communicating here is that you don't regularly work with Python.

The claim that you have to look up len seems disingenuous; I might believe it if you didn't look like a speaker of English.

> & means where

And that's something any engineer would know, unlike having to look up what len means?

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

#84
post #73
post #9

A bit sad that this interesting content is not available for audio/video impaired readers.

I have just finished transcribing it (quite roughly) https://gist.github.com/rak1507/3aec8c0b720e6d8a9ef121fc14e4...

wow! much appreciated, many thanks!

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

#86
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…

Let's do this using the same approach, "find indices and assign over them in a copy of the sequence": This is the TXR Lisp interactive listener of TXR 259. Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet. Do not operate heavy equipment or motor vehicles while using TXR. 1> (defun subst-select-* (list) (let ((indices (where (op starts-with '(select *)) (cons nil (conses list))))) (if indices (let (…

If this were me, and I needed a function like us, I would have written this:

    us:{$[x~(z;y);,"_";y]}[(*K;,"*")]':
I would be interested in seeing anything that was shorter[1] and faster than that in any language, and I would be very curious to learn from anyone who could also do that faster than me.

But I'm not a fetishist: I didn't learn k because it was cute, and I don't wake up every day looking for ways to rewrite other people's code so that it is slower and bigger. Do you? Or is today special?

[1]: Measured in source-code bytes.

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

#87
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…

Wow. That's some explanation. Thanks. Do you use "rainbow brackets"? This example is first hit I found: https://kristofferc.github.io/OhMyREPL.jl/latest/features/ra... Such an obvious idea once you see it. Wish I had syntax coloring and rainbow brackets when I coded LISP for hire.

> Wow. That's some explanation. Thanks.

Happy to help.

> Do you use "rainbow brackets"?

No. I flash brackets, but I tend to turn off other forms of syntax highlighting. I find it extremely distracting when the syntax highlighter "decides" wrong, and I've become convinced comments at the end of lines like //} to "fix" the highlighter deal with complicated stuff is hurting more than it's helping.

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

#88
post #86

Earlier quoted context omitted.

Let's do this using the same approach, "find indices and assign over them in a copy of the sequence": This is the TXR Lisp interactive listener of TXR 259. Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet. Do not operate heavy equipment or motor vehicles while using TXR. 1> (defun subst-select-* (list) (let ((indices (where (op starts-with '(select *)) (cons nil (conses list))))) (if indices (let (…

If this were me, and I needed a function like us, I would have written this: us:{$[x~(z;y);,"_";y]}[(*K;,"*")]': I would be interested in seeing anything that was shorter[1] and faster than that in any language , and I would be very curious to learn from anyone who could also do that faster than me. But I'm not a fetishist: I didn't learn k because it was cute, and I don't wake up every day looking for ways to rewrit…

> I would be interested in seeing anything that was shorter

One way to do that would be to pose that as a problem on the Code Golf Stackexchange.

My rewrite-case solution condenses (by removal of all non-essential spaces) to 69 bytes if the symbols are in a hash table K, and the input list is in a variable y, rather than a big literal:

  (rewrite-case x y((@[K @sym]* . @rest)^(,sym _ . ,rest))(@else else))
A one-letter name could be chosen for the macro. Furthermore, one-letter names could be chosen for sym, rest and else:

  20> (r x y((@[K @s] * . @r)^(,s _ . ,r))(@e e))
  (foo bar * select _ fox where _ bravo)
Still working! Now down to 43 bytes.

(It's not because I cannot that I do not do this with all my code.)

Doh, why use . ,r in the backquote if we are golfing? That should be ,*r: using the splice operator, like Common Lisp's or Scheme's ,@, getting us to 42 bytes:

  20> (r x y((@[K @s] * . @r)^(,s _ ,*r))(@e e))
  (foo bar * select _ fox where _ bravo)
I suspect Code Golf Stackechange regulars could get it down to way in one of the dedicated golfing languages like Retina or what have you.*

What else can we do? The @[K @s] predicate syntax could be replaced by a custom operator defined by defmatch, looking like @(K s).

  21> (defmatch k (sym) ^@[K (sys:var ,sym)])
  k
  22> (r x y((@(k s) * . @r)^(,s _ ,*r))(@e e)) ;; 41
  (foo bar * select _ fox where _ bravo)
Just noticed the ) * is not fully golfed:

  23> (r x y((@(k s)* . @r)^(,s _ ,*r))(@e e)) ;; 40
  (foo bar * select _ fox where _ bravo)
The k pattern operator macro could be non-hygienic: it could implicitly bind a variable called s:

  24> (defmatch k () ^@[K @s])
  k
  25> (r x y((@(k)* . @r)^(,s _ ,*r))(@e e)) ;; 38
  (foo bar * select _ fox where _ bravo)
These last few feel like cheating because they are too special purpose. Defining anything you can only possibly use just once isn't making the overall program smaller.

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

#89
post #86

Earlier quoted context omitted.

Let's do this using the same approach, "find indices and assign over them in a copy of the sequence": This is the TXR Lisp interactive listener of TXR 259. Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet. Do not operate heavy equipment or motor vehicles while using TXR. 1> (defun subst-select-* (list) (let ((indices (where (op starts-with '(select *)) (cons nil (conses list))))) (if indices (let (…

If this were me, and I needed a function like us, I would have written this: us:{$[x~(z;y);,"_";y]}[(*K;,"*")]': I would be interested in seeing anything that was shorter[1] and faster than that in any language , and I would be very curious to learn from anyone who could also do that faster than me. But I'm not a fetishist: I didn't learn k because it was cute, and I don't wake up every day looking for ways to rewrit…

> Do you? Or is today special?

Today is the usual. He does that in all threads related to array languages.

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

#90
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…

> I have to look up range/xrange and len and memorise All you're communicating here is that you don't regularly work with Python. The claim that you have to look up len seems disingenuous; I might believe it if you didn't look like a speaker of English. > & means where And that's something any engineer would know, unlike having to look up what len means?

> The claim that you have to look up len seems disingenuous

In what way?

I have to look up "how do I get the indices of a list" to get range(1,len(x)) -- I think I could have also used enumerate() and a bunch of other things, but this seemed the shortest.

> All you're communicating here is that you don't regularly work with Python.

I hope I'm communicating more than that because I put a lot of effort into my comment. I don't regularly work with k either.

What exactly do you think you are communicating?

Post reply on HN