« first day (2312 days earlier)      last day (636 days later) » 

15:01
Welcome to APL Quest 2019-6! Today's quest is Area Code à la Gauss:
> Given a nested list of pairs of numbers describing the points of a polygon in two dimensions, compute the area of the polygon using Gauss' area formula, also known as the shoelace formula.
      (your_function) (2 4)(3 ¯8)(1 2)
7
      (your_function) (1 1)   ⍝ a point has no area
0
      (your_function) (1 1)(2 2)   ⍝ neither does a line
0
Just a fast one. And a lot of duplicate code wich probably can be removed
{|2÷⍨(+/¯1↓×/(0 1)⊖⍵)-+/¯1↓×/(1 0)⊖⍵}{↑⍵,⊂⊃⍵}⊆
yeah feels like an over perhaps, but I see you're concatenating the first value (like in the description on the problem page) in a similar way to @RubenVerg
yes
p.s. try apl freezes so didn't test it
huh that's odd - it's working for me
than it's just my browser, np.
@RubenVerg used ,⍤⊆. is just ⊆ not sufficient?
15:07
so you're taking the products of the two rotations separately and then subtracting them
I've got one that does the steps as 3 reductions: -/+/×/
before I show that code, any guess how I did it?
@RikedyP yes. Just followed litteraly the description.
@RikedyP No. I saw Ruben also use ×, but didn't grap it.
how can you get a single array (3D) with the contents of (0 1⊖⍵) and (1 0⊖⍵), without simply joining those two
@RubenVerg imho the only obscure part is the 2+.÷⍨ instead of 0.5×+/ or 2÷⍨+/
it also took me a minute to grok, but otherwise it's a decent algorithm - note that it's a pair-wise reduction 2F/which is not immediately obvious with all the tacit going on
2-/⍤×∘⌽/⍵ ⍝ difference of product of each point (xy) with reversed right-neighbour
So I've got:
Gauss←{0.5×|-/+/×/(2 2⍴0 1 0 ¯1)⊖⍤1 99↑,⊆⍵}
@RikedyP no idea, sorry
@Richard np, see above
So if I were to summarise it, I'd say:
@Richard has broken things apart in the code itself, and expressed each part of the algorithm as a piece of code
@RubenVerg took a more functional approach and devised a pair-wise reduction
I manipulated the shape of the data to get the algorithm expressed as reductions
yes that's nice
15:16
I think we all have some version of ,⊂ to deal with the simple vector (one point, 0 area) case
but the , is not necessary, is it?
using ⊆
for us who mixed, it is
↑,⊆
otherwise gives back the same vector and I get a RANK ERROR. I'm not sure for yours
and @RubenVerg kept everything nested anyway
because you're catenating the first point you get a matrix after ↑⍵ regardless
yes, just tried it. Always find that difficult
any questions about these 3? I'll have a brief think if we can put an over in yours
@RikedyP Yes please, was thinking about that
15:21
which bits of code are repeated exactly?
+/¯1↓×
almost
inlcuding the / of course
there we are :P
copy paste error
15:22
so in ⍺(F⍥G)⍵ what's the F and what's the G?
and what are and for that matter :P
G is the preprocess part. So +/¯1↓× is F
ah well it was 50/50
G is the rotate
:(
other way around. The repeated part is the pre-process
what are you doing with the two things? Hint: it's dyadic
well that hint was useless...
what are you doing between the two values after pre-processing them?
But we are first doing the rotate, and then the reduce etc.
15:26
yeah that's all pre-processing
in this instance
and unfortunately we can't factor out the rotations because of the different arguments (unless we use Rank operator like I did)
so for F⍥G, G is first applied
On ⍺ and ⍵
maybe it would help if you guess the and first
actually I'll just say
they are the rotated s
⍺←0 1⊖⍵ ⋄ ⍵←1 0⊖⍵
⍺ and ⍵ are the ⊖
So we've done the rotations before we get to the F⍥G
(0 1⊖⍵)F⍥G(1 0⊖⍵)
Apply G to both arguments, and apply F between the results of those applications
ah, and F is then |2÷⍨
15:30
no you've gone too far into the future there
well you could tie them in as an atop, but not worth
just the -
G already has +/
ah yes, we are substracting them after rotating them both
*after summing the products of both
summing the products of the rotations - but we didn't factor out the rotations, so those are still explicitly applied to our argument
yes, ...
15:33
wanna have a stab at putting it together? Or shall I paste it?
working on it :)
(0 1⊖⍵)-⍥/¯1↓×/ (1 0⊖⍵)
but probably needs a ∘ somewhere
you're really quite close, although have forgotten the sum
is TryAPL still playing up for you? Can I ask your web browser and operating system?
and perhaps also recommend you download Dyalog APL :P
@RikedyP can't remember why I did that
firefox, but I am using the interpreter
I suppose I accidentally assumed it was shorter
golf brain kicked in :)
15:37
NP is just my computer
@RubenVerg yeah I figured
@Richard
|2÷⍨((0 1)⊖⍵)-⍥(+/¯1↓×/)(1 0)⊖⍵
@RubenVerg is shorter than mine
Not my best week...
@RikedyP I still don't fully get the rules for when a tacit chain stops, but I noticed that I didn't need any parens around the reduction for it to work, it's definitely much clearer with
@Richard not bad at all
@RubenVerg well you've really only got a 2-train in the overall function
the left tine is just a dfn, with a tacit function made using function composition operators
A train is always just a function isolated from its arguments
You can isolate functions by either using parentheses ⍺(FGHIJKL)⍵ or by assigning a name Train←FGHIJKL
why does it not parse as a fork ((2)(-/ after × composed with reverse)(/))?
sorry don't have an APL keymap on hand
15:42
@RubenVerg because function composition operators already bind those symbols into a single function
so it would be a 1-train
the / operator probably goes first
which is just function application
oh right because here / is an operator
the thing with / being both operator and function is confusing
so you could do
2(-/×∘⌽)/ ⍝ perhaps
@RubenVerg indeed it is, although you can get used to it with time, but if we started over definitely wouldn't have that
but that's not the thing preventing a train from forming here, it's your use of atop and beside
@RikedyP that's longer is it? I think the extra composition is clear enough
15:44
@RubenVerg yeah longer by 1. Note that a 2-train is an atop
right
I only brought it up because you asked why what you had wasn't a train
and having thought for a second, it is indeed both due to / being an operator and your use of compositions
also do I actually need such a long expression for x,x[1]?
seems weird it isn't shorter
x,1⌷x
same length
Yeah I mean there's no primitive for "concatenate the first bit"
(⊂∘⊃,⊢)⍵
@RikedyP used that in the last one, decided to go with enclose disclose just for variatio
idk how to say in english
15:50
variety
yeah fair enough
you call it variety also in poetry?
not sure I understand the question
you mean is there a fancier word for variety?
@RikedyP (⊣,⊂∘⊃)⍵
@Richard indeed
in Italian "variatio" is specifically using two language constructs to mean the same thing
15:51
right any last Qs before I dip out?
@RubenVerg oh probably synonyms then?
but how broad is "constructs" in that definition?
wait I'll look for an example
variation v.s. variety
you'd say "a variation" as the thing that is different, whereas variety is just the quality of having differences
@RikedyP like complements
@RubenVerg yeah that's also a term with a few meanings in English, but I think I get the gist
I think "variation" as @Richard said is maybe closest
15:54
okay this seems to not exist in english so nevermind
thanks all, CY next week
anyways it's like a rhetorical figure
like in music too? if you have a theme
okay here is a translation of a dictionary definition
@Richard Thanks as always @Richard
@RubenVerg yes please let's see before I go
15:57
variatio: Rhetorical principle opposed to repetition, to which many [rhetorical] figures are connected, like polyptoton and synonimy, and many more. These can be used to get a variation in speech and therefore avoiding monotony.
the roman poet Sallust is known for using variatio very often
Oh so it includes several rhetorical concepts in the one word "variatio"
it's like a family of figures
yeah not sure we have that in English as a single word
and a style of writing
it says "opposed to repetition", but I'm guessing the idea is you want to say the same thing again (for effect) but not literally use the same phrase again
16:00
repetition here refers to specifically using the same words/construct next to each other
Yeah it's just called "variation" in English I think
iteratio in latin/specific lexicon for poetry in italian
maybe our poetry is not as good ;)
anyway thanks for your contributions today - see you around !
Next week will be 2019-10: Odds & Evens
 
2 hours later…
17:32
@RikedyP and probably slower too, especially as 2F/ with comparisons and simple mathematic fns (think just +×÷-) optimised.
likely
 
2 hours later…
19:15
is there a way to add a line break without ending an expression?
like \ in python or c

« first day (2312 days earlier)      last day (636 days later) »