News for hackers. Stuff that matters.
Re:Thinking in an Array Language by gcanyon on Saturday January 13, 2024 @01:25PM (#38982904)
This is based on K. Another array language is J http://jsoftware.com In J this would be:

   dot =: +/ . *
   P =: 2 3 4
   Q =: 1 0 2
   P dot Q
That will return 10, the dot product P and Q.
Re:Thinking in an Array Language by abrudz on Saturday January 13, 2024 @03:45PM (#38984367)
The original array lang is APL:

    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).
Re:Thinking in an Array Language by gcanyon on Sunday January 14, 2024 @09:40AM (#38990801)
For people who understand the language, there is little point to naming it. For illustrating to people unfamiliar with the language, it helps to break apart the "this is the thing I'm talking about" part from the "here's how you would use it" part.
Re:Thinking in an Array Language by eismcc on Saturday January 13, 2024 @02:38PM (#38983693)
In KlongPy, dot product is: dot::{+/x*y}

    P::[2 3 4]
    Q::[1 0 2]
    dot(P;Q)
Re:Thinking in an Array Language by __marvin_the__ on Saturday January 13, 2024 @10:06PM (#38987036)
TIL of KlongPy (and Klong). Looking at the project page, I think it looks really cool.

https://pypi.org/project/klongpy/

Re:Thinking in an Array Language by nils-m-holm on Sunday January 14, 2024 @05:17AM (#38989142)
> dot(P;Q)

You can also write P dot Q.

Re:Thinking in an Array Language by akavi on Saturday January 13, 2024 @10:16PM (#38987087)
I guess I still fail to see the advantage of this over Haskell:

    dot = (sum.) . zipWith (\*)
    p = [2, 3, 4]
    q = [1, 0, 2]
    p `dot` q
Like, the only difference to my eyes is using names for sum/zipWith, and not having the lifts/restructuring happen "magically"
Re:Thinking in an Array Language by RodgerTheGreat on Saturday January 13, 2024 @11:08PM (#38987354)
The APL/J/K/Klong versions are more general; they all work for a variety of ranks of input, whereas the Haskell version- which is the longest and most visually noisy- bakes in a single rank's mapping explicitly.
Re:Thinking in an Array Language by radiator on Sunday January 14, 2024 @01:23AM (#38988023)
Well, for one, your Haskell version is obviously much longer.
Re:Thinking in an Array Language by dr_kiszonka on Sunday January 14, 2024 @04:06AM (#38988749)
Haha!