« first day (1955 days earlier)      last day (686 days later) » 

3:00 PM
Welcome to APL Quest 2014-8! Today's quest is Go The Distance:
> Write a dfn that returns the distance between two points in a space of any number of dimensions.
So, the formula for this is pretty simple: √((x₂−x₁)²+(y₂−y₁)²+(z₂−z₁)²+…)
 
0.5*⍨1⊥2*⍨-
 
From APLcart? ;-)
Oh, wait, it isn't exactly the same spelling.
 
Can't paste my solution but squared the input, added each element and took the square root.
 
There are two "inputs" (arguments).
 
The same I guess as RAbbit
 
3:03 PM
@Adám No, no cheating :)
 
Yeah, sorry. I didn't notice that yours was unique.
 
I had {*∘.5+⌿*∘2⊢⍺-⍵}
 
obligatory +/⍢(×⍨)-, using Under (×⍨*∘2 to make it run in dzaima/APL)
 
@Adám yes, squaring the difference
 
@doug Interesting how you bind right args to create monadic square and squareroot fns.
@dzaima Yup. *∘2⊢ could also be ×⍨
This one is fun: +.×⍨⍤-*.5⍨
 
3:06 PM
@Adám (misedit?)
 
ngn/k, 11 bytes: %+/*/1{x}\-
 
I’m not sure what I was thinking at the time. : )
 
@dzaima Yeah, that additional comment should have been for @doug
My fun one isn't shorter than rabbitgrowth's, though.
@PyGamer0 How does that work?
 
@Adám subtract -> square (basically catanate to self and reduce by multiplication) -> sum -> sqrt
 
Now I get how rabbigr’s works. It’s essentially the same but fancier. I still don’t have a great feel for how performance is impacted.
 
3:09 PM
@Adám nice. I always forget outer product
 
Inner.
 
@PyGamer0 {x} looks funny..
 
Yes
 
@PyGamer0 I don't understand what the 1{x} is doing (as operand to \?)
 
@Adám it's like a cumulative , repeating {x} once, and giving the original and new results as an array
 
3:11 PM
Ah.
 
ovs
@PyGamer0 Why does %+/{x*x}- not work?
 
@ovs {x*x} is a noun. You need %+/{x*x}@-
 
@PyGamer0 Isn’t 1{x}\ just 2#
 
@doug yea
 
@doug Use doubled backticks. (Not too late to press UpArrow and edit.)
 
3:12 PM
@doug hmm true
@doug no that doesnt work
for some reason
 
@Adám tx
 
2#, did the trick
 
needs to be 2#,
 
is interesting. Also it looks so happy
 
Speed more or less the same for all of them I assume?
 
3:15 PM
@rabbitgrowth The one you need here can be defined as {⍺←{⍵ ⋄ ⍺⍺} ⋄ ⍵⍵⍣¯1⊢(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵)}
@Richard I think so.
I can't really think of anything else to add here.
 
Imaginary input also works?
 
Yes, but though multi-dimensional complex vectors are maybe not so meaningful.
 
I gues it should
 
OK, then I'll run. See you next week.
 
,l👍
 
3:20 PM
@PyGamer0 FWIW: variants
 
3:44 PM
@Adám Would you mind explaining the ⍺←{⍵ ⋄ ⍺⍺} part?
 

« first day (1955 days earlier)      last day (686 days later) »