HN user

abrudz

238 karma

https://apl.wiki/adam

Posts1
Comments91
View on HN

Yes, it can also a fork where A is an array while B and C are function and a tacit atop where either B is a monadic operator and A its array or function operand or A is a function and C is a monadic operator with B being its array or function operand. Finally, it can be a single derived function where B and C are monadic operators while A is B's array or function operand.

Also (mind the year this is from!):

— Can you teach a computer to write poetry?

— If you can teach it--yes, there's nothing easier. One of the things is that you could do, for example, you could simply give it a collection of poems or prose or whatever you have, and then provide a program which selects pieces from these, either individual words, individual phrases, individual passages, and so on, and merges them together according to some criterion, which you would then write into the program, and also with a certain element of chance. Usually, you know, you'd say, "Well, you want to pick this sometimes, that sometimes." Yes, you can write it, but you raise the question, what would be the point?

Think "normal" call syntax like

  foo(bar(baz(42)))
and then remove the superfluous parens
  foo bar baz 42
The expression is evaluated from right to left.

Now, let's make two of the functions into object members:

  A.foo(bar(B.baz(42)))
Remove the parens, extracting the methods from their objects, instead feeding each object as a left argument to its former member function:
  A foo bar B baz 42
This is normal APL-style call syntax; right-to-left if you want.

APL brings another couple of ternaries (besides for those mentioned with regards to J):

  x f[k] y
This one is universal among traditional APLs (though some modern APLs, including J, remove it). However, it is traditionally only used for a concept of application along an axis of APL's multidimentional arrays, and only for a strictly limited set of built-in "operators". That said, GNU APL and NARS2000 both allow it on user-defined functions (which have infix syntax, just like "operators").
  x n.f y
This is infix application of the function f from the namespace n, so n must have namespace value, but it is still a proper argument because n isn't just an identifier, but can also be an expression:
  x (expression).f y
In fact, the expression can be an entire (multidimentional!) array of namespaces:
  x (namespace1 namespace2).f y
is equivalent to
  (x[1] namespace1.f y[1])(x[2] namespace2.f y[2])
Furthermore, f can be a built-in "operator" which appears to exist in every namespace, but which also takes the current namespace into consideration. For example, x⍳y is the position of y in x and if io0 is a namespace wherein indexing is 0-based and io1 is a namespace wherein indexing is 1-based, we can write:
  'AX' 'BX' (ns0 ns1).⍳ 'X'
and get the result 1 2 because X is at position 1 in AX with 0-based indexing but at position 2 of BX with 1-based indexing. (I'm not saying you should write code like this, but you could.)

It is indeed Dyalog APL (evident by certain features used, and also what Co-dfns requires). And yes, I agree, especially since this uses the ".apl" file extension of GNU APL, rather than the ".apls" that Dyalog uses for shell scripts. Oddly enough, the "⎕IO←0" appears outside the ":Namespace" which means it cannot be used by other APL code.

That's a very good point, but it requires a lot of code:

  <form id=theme>
    <label for=theme-l>light</label><input id=theme-l type=radio name=theme value=l>
    <input id=theme-d type=radio name=theme value=d checked><label for=theme-d>dark</label>
  </form>
  <style>
    input:checked{position:relative;z-index:1}
    input+input{margin-left:-1em}
  </style>
It is ugly, hard to style right, doesn't have toggle semantics, and needs strange code like theme.theme.value to get the value.

I'd much rather write:

  <select type=switch id=theme>
    <option value=l>light</option>
    <option value=d selected>dark</option>
  </select>
And it'd be an actual switch with one label on each side and I'd get the value with theme.value

Please don't support making switches be an alternative to checkboxes, since it isn't clear what the current state means. I do like the idea of switches, but they should only be used to select one of two labelled choices but usually not yes/no, as a checkbox does well there. See e.g. https://abrudz.github.io/sans/ where I use four switches to choose between binary non-yes/no options.

Make a new element or input type that makes it easy to do switches right, with two labels.

APL at Volvo 2 years ago

But to me as a relatively experienced APLer, it reads very clearly as "return if there are no non-ASCII chars in `w`" (and if there are, the indices of those chars will be stored in `i` and the code point of every char will be stored in `c`).

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).
k on pdp11 3 years ago

That's not Eratosthene's sieve, but rather a naive O(n²) algorithm, implementing "a prime never occurs in the multiplication table".

k on pdp11 3 years ago

Try that experience at https://tryapl.org

Enter 1+2 where the cursor is below the copyright notice.

Now click or use arrow keys to navigate up and change the 2 to a 4 and hit Enter again.