0

The Google’s Ivy interpreter is a APL-like math language. This is an example of first N primes numbers algorithm in Ivy/APL

op primes N = (not T in T o.* T) sel T = 1 drop iota N

Could someone describe the notation for the primes algorithm here?

Ivy/APL doc is here.

1 Answers1

1

It can be directly translated to APL from the vocabularies provided in the doc.

{(~T∊T∘.×T)/T←1↓⍳⍵}

someone who have learned the notation of APL might already figured it out, but since APL isn't very popular, here's an attempt of explanation:

it means assign T with dropping first element of iota N, which is a sequence of numbers 2..N, then filtering out those that belongs to `T∘.×T that is the outer product, what been left are the primes.

LdBeth
  • 126