Announcement: DuckDuckGo now has an !aplcart bang; you can search directly on APLcart by entering !aplcart with your query. This also works in your URL bar if you use DDG as your browser search engine.
Given the integers p, q and n I would like to generate a vector of length n with the elements
(⌊p ÷ q) (⌊(⌊p ÷ q) ÷ q) ...
In other words I want to construct a vector where the i:th element is {⌊⍵ ÷ q} applied i times on p. How can I do that in APL?
@Adám i don't know, either something like that or a separate squiggle. in k they are just / and \. obviously, apl can't do that because it doesn't know the valence of functions in advance to tell apart "reduce" from "converge", and "scan" from "converge-iterate" (or whatever fancy name it has now)
@Adám like in Haskell, e. g. unfoldr (\x -> if x>0 then Just (-x, xdiv2) else Nothing) 42 is [-42,-21,-10,-5,-2,-1]. Here function returns (a) what elem goes to the result (-42), (b) the next state (xdiv2 aka {⌊⍵÷2}), (c) whether to stop (Just(v,state) or Nothing). Shouldn't be necessary that complex, but the idea is this.
@ngn that -x is not necessary, just a (simple) way to do unfoldr (\x -> if cond x then Just (x, next x) else Nothing) a₀ would be nice [But that's just me, and I'm only "using" APL for 2 weeks, so maybe I'm completely wrong]
think i'm finally going to try to somewhat optimize my line parsing code. though it's fun, it's annoying to have to write everything performance-requesting in train form :/