« first day (862 days earlier)      last day (1775 days later) » 

10:02 AM
i keep thinking about this algorithm, i found one way to do it but it feels pretty ineffecient, curious of other people have ideas :)

say you have an input array like `1 4 5 6 9 13 17 18 100 101 104`, you can assume all elements are positive and the array is monotonically increasing

the result you want is an array of arrays, of all subsequences where the next number is n+1, so for the above example you would want (1) (4 5 6) (9) (13) (17 18) (100 101) (104)
the kinda miserable way i did it in k is {|1_|1_{*|x}'{|a@&:'~:\0=a-(*a)+!#a:*x}(,x)}, which repeatedly lops off the sequence from the front, but i feel like this has a way higher algorithmic complexity than is necessary since it does a calculation over the entire input array each time
it feels to me like there must be some clever way to use partition or partitioned enclose here
(sidenote: typing apl characters on a german mabcook keyboard for the first time is a real trip)
the apl equivalent would be {⍬≡⍵:⍬⋄(⊂m↑⍵),∇⍵↓⍨m←+/0=⍵-(⊃⍵)+⍳≢⍵}b i guess
 
ngn
10:24 AM
⎕←{⍵⊂⍨¯1≠1,2-/⍵}1 4 5 6 9 13 17 18 100 101 104
 
@ngn
┌─┬─────┬─┬──┬─────┬───────┬───┐
│1│4 5 6│9│13│17 18│100 101│104│
└─┴─────┴─┴──┴─────┴───────┴───┘
 
ngn
@dogstar ^
 
oh damn i was way overthinking this
@ngn thanks :)
i should read the manual section on partition so i have a better intuition for it, i guess
 
ngn
small correction: {⍵⊂⍨1,¯1≠2-/⍵} - the 1, wasn't at the right place
 
ngn
10:39 AM
 
@ngn oh wow - i had no idea _ had that functionality
or that i could specify the initial value for each-pair, but that's more intuitive to me
 
ngn
@dogstar dyadic _ with a list on the left is "cut", it's an extension of _ as "drop"
 
makes sense - didn't see it on ref or in \h so i didn't know it existed. should probably spend more time rummaging through the other docs.
i guess the -1 is to just make sure that first element will always be >1?
 
ngn
@dogstar yep
 
very cool
 
ngn
10:50 AM
@dogstar you said "positive" and i assumed it means >0 but to be safe i should have used -2
 
yeah, i meant natural numbers
 
ngn
that's ambiguous
 
is it? i meant >0 then
 
ngn
@dogstar "Some definitions, including the standard ISO 80000-2, begin the natural numbers with 0" -W
 
reading into it, i guess it is ambiguous - had just always learned that it didn't include 0
good to know
 
ngn
10:53 AM
in french-speaking countries "positif" includes 0, so that causes confusion sometimes
including in this year's apl competition :)
 
need to get back at that :p
was having some trouble logging in and felt too lazy to figure it out earlier
 
ngn
Romberg's method: "takes a positive integer left argument" and then "example: (¯1+⍳4)⍟Romberg¨..." @RichardPark @Adám
@dogstar cut is not in chrispsn's docs yet but it's mentioned in johnearnest's
 
i guess i can make myself useful and submit a pr to add cut :)
but this has also made me have a realization that k's terse documentation is probably that way to force me to start coding k more intuitively, thinking about what makes sense for overloaded behaviors. that or they're just not spending much time on the docs :)
 
12:13 PM
@ngn I asked for it to be written "strictly positive" or "non-negative" but that was turned down :-|
 
Ven
12:46 PM
@ngn wait, it doesn't in other countries?
We often qualify it, tbh. "Strictly positive".
 
In Portuguese, "positivo" usually won't include 0.
Because strictly speaking, 0 is not positive.
 
@J.Sallé this was also my (american) understanding :)
 
ngn
1:34 PM
@Ven afaik it doesn't. for most of the world positive is >0 and non-negative is ≥0
"non-negative" admittedly being a very ugly word
 
CMC: Given a number, return a Boolean vector (strictlyNegative,nonPositive,isZero,nonNegative,strictlyPositive)
 
ngn
i wonder if this would make sense in french :) "i have good news and bad news - there isn't any news"
 
@Adám should this return 0 0 1 0 0 or 0 1 1 1 0 for 0?
Because technically 0 is both nonPositive, nonNegative and isZero
 
@J.Sallé 0 1 1 1 0
 
ngn
"homeopathy had positif effect on my health" :)
 
1:42 PM
@Adám then I have a very naïve 0∘(>,≥,=,≤,<) as solution
Mostly because I'm too lazy to think of a prettier one, I confess.
 
@J.Sallé Yeah, I was interested in whether one could reuse some of the info, as ~> is the same as
Nah.
Of course, in Extended, it is just >,≥,=,≤,<
 
Ven
I was thinking that too :)
 
If the problem was just >,≥,≤,< then 1 0 0 1⌽⍨× is an interesting (albeit longer) solution.
 
ngn
2∨/2/0(>,=,<)⎕ but it's longer :(
 
2:01 PM
@ngn Any particular reason for instead of ?
 
ngn
@Adám hm... i thought it wouldn't form a train
 
@ngn the / function is safe in trains when accompanied by a calming constant.
Slash-functions may only be in our trains when accompanied by a calming constant or a responsible operator.
3
 
Ven
Beautiful.
 
3:03 PM
@Adám will it just panic and break everything down without the constant?
 
3:53 PM
@J.Sallé It'll freak out and require an operation.
Is the act of an operator binding a function called an operation?
 

« first day (862 days earlier)      last day (1775 days later) »