« first day (1979 days earlier)      last day (665 days later) » 

12:42 AM
⍝ Given a vector 1 2 3 4 , try to generate vector of vector [[1 2 3 4], [2, 3, 4], [3, 4], [4] []]
f ← {⍺ ↓⍨ ⍵}
1 2 3 4 f 1
┌→────┐
│2 3 4│
└~────┘
I have the function, but I could not figure out how to apply the function on each element of a number such 0 1 2 3 4
 
you may be interested in ,\
but using your original idea, you can use ¨ and ⊂ to do what you want
 
v ← 1 2 3 4
v f¨ (-1 + v)
┌→────────────────┐
│ ┌⊖┐ ┌⊖┐ ┌⊖┐ ┌⊖┐ │
│ │0│ │0│ │0│ │0│ │
│ └~┘ └~┘ └~┘ └~┘ │
└∊────────────────┘
 
 
6 hours later…
6:40 AM
@elliptic00 ⎕←{(⌽0,-⍵)↑¨⊂⍵}⍳4 ⋄ (⊂↑¨⍨∘⌽0,-)⍳4
 
@Adám
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
 
7:01 AM
⎕IO←0⋄(⍳∘≢↓¨⊂∘⊢)1 2 3 4
⎕← ⎕IO←0⋄(⍳∘(1+≢)↓¨⊂∘⊢)1 2 3 4
 
@doug
0
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
 
@rak1507 D'oh! I missed this. Sorry if I spoiled the hint.
 
8:05 AM
⎕←⌽⌽¨,\(⊂⍬),⌽⍳4
 
@Adám
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
 
⎕←⌽⌽¨1↓¨,\0,⌽⍳4
 
@Adám
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
 
 
3 hours later…
10:46 AM
⎕←⍬,⍨⌽⌽¨,\⌽1 2 3 4
 
@PyGamer0
┌───────┬─────┬───┬─┐
│1 2 3 4│2 3 4│3 4│4│
└───────┴─────┴───┴─┘
 
Nice one. Technically we've been making the last box empty.
That's what the ⊂⍬ is doing in Adam's version above.
 
11:04 AM
You could do ⍬,⍥⊆⍨
 
{(⌽(-⍳≢⍵)↑¨⊂⍵),⊂⍬} - a solution without ,\
{⌽¨⌽,\⌽⍵,⊂⍬} also seems pretty cool and short
even cooler when you realise that you can do stuff like ⋄⌽¨⌽,\⌽1 2 3 4 ⍬
 
@KamilaSzewczyk
┌───────┬─────┬───┬─┬┐
│1 2 3 4│2 3 4│3 4│4││
└───────┴─────┴───┴─┴┘
 
 
3 hours later…
2:33 PM
Is there a way to limit the output of long results in the repl?
 
@pamphlet Yes, have a look at ]rows
 
@Adám Looks perfect. Thanks!
 
 
5 hours later…
7:18 PM
k ← {x ← {⍺} ⋄ ⍵ + x}
APL does not support inner function?
 
7:44 PM
What are you aiming to do?
APL does support nested functions: ⎕ ← {x ← {⍵} ⋄ - x 1 }0
Each dfn will create it's own scope however
If you wanted to use ⍺ from the top-level function, you'd have to assign it to a variable.
 
8:12 PM
@awagga, Ok, my mistaken,
 
 
2 hours later…

« first day (1979 days earlier)      last day (665 days later) »