apltacit-programming

Check that each adjacent pair of a list is in order (tacit programming) in APL


Given a list in APL I would like to check that each adjacent pair is in order. So, given (a0, a1, ..., an), I would like to calculate:

(a0 ≤ a1) ∧ (a1 ≤ a2) ∧ .... ∧ (a[n-1] ≤ an)

I don't want to compute an equivalent form and I want to use tacit programming. My solution is ((¯1↓⊢)∧.≤(1↓⊢)) but it seems too verbose. Does anyone have any ideas?


Solution

  • ∧/2≤/⊢

    X f/ Y computes the f-reductions in Y using sliding windows of size X. Therefore, if X←2 then we get pair-wise reductions, or in other words, insertion of f between subsequent pairs. is needed to complete the 3-train 2 ≤/ ⊢ and then we just have to AND together all the resulting Booleans using ∧/