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

1:10 PM
⍺⍺
∇distinct ∇each ⎕CS
That's a little odd, isn't it? I'm not using ⎕CS, and certainly not passing it in directly.
It must relate to the fact that the all the code is executing in a :Included namesapce.
Bug or feature?
 
1:22 PM
@PaulMansour Sounds strange. Can you send the entire repro (maybe to support?)?
 
1:36 PM
@Adám Will do. I'll try and come up with a small repro.
 
Thanks!
 
2:34 PM
@Adám what is your solution
 
@PyGamer0 A tradfn:
y←f(x)
 
2:56 PM
Don't you mean x←f(x) ?
 
Yes, of course. Sorry.
Welcome to APL Quest 2015-1! Today's quest is Nag A Ram:
> Write a function that takes two character vectors as its left and right arguments and returns 1 if they are anagrams of each other.
We need to ignore spaces, capitalisation, and punctuation.
 
≡⍥((⊂⍤⍋⌷⊢)⎕A∩⍨1∘⎕C)
 
s[⍋s←⎕C ⍺/⍨⍺∊⎕A,⎕C ⎕A]≡t[⍋t←⎕C ⍵/⍨⍵∊⎕A,⎕C ⎕A]
 
Both of these are very good.
@Richard You're implementing the set function yourself. And while you're doing the same preparation on both arguments, you could use
 
Could you please explain that?
 
3:03 PM
@rabbitgrowth While slightly less efficient, you could make it neater by sorting first, then doing the uppercasing and intersection.
@Richard ⍺/⍨⍺∊⎕A,⎕C ⎕A selects the elements from which are members of ⎕A,⎕C⎕A
That is the set intersection of and ⎕A,⎕C⎕A i.e ⍺∩⎕A,⎕C⎕A
 
ah, ok!
 
And then, since you're pre-processing both arguments, before feeding them to you could use ≡⍥g where g is the pre-processor.
 
@Adám Would that work correctly? anagram sorted is aaagmnr and Nag A Ram sorted is ANRaagm
 
Yes, but then you do the intersection and casefolding afterwards. (And no, chat won't let you have leading spaces.)
@rabbitgrowth Oh, wait, my bad. Of course!
So, with my mistake out of the way, how can we golf this the most?
It is a bit annoying that ⎕C lowercases (Latin letters) while ⎕A is uppercase.
My shortest:
 
yes, why is ⎕A not lower case? Or maybe a 1⎕A and a 0⎕A for upper and lower case
 
3:13 PM
≡⍥{t[⍋t←⍵∩⍥⎕C⎕A]}
≡⍥((⍋⊃¨⊂)∩⍥⎕C∘⎕A)
⎕A is probably uppercase for the historical reason that there were no lowercase letters in early APL.
But ⎕A is a constant, not a function/operator. You can't give it a parameter, and certainly not on the left.
 
yes, true
 
Some APLs added ⎕a but that breaks the principle that quad names are case insensitive.
 
@Adám is a good readable solution
 
And now that we have ⎕C⎕A there's really no reason to add a lowercase alphabet, other than for code golf.
Something to ponder is that both your solutions only consider uppercase and lowercase Latin letters.
The problem statement is actually in the negative; ignoring punctuation.
So, how might we include all letters, including non-Latin ones?
And how might we exclude all punctuation?
 
what is punctuation else than everything but the letters? I searched in Google hoping to find it was only a small set of characters
 
3:21 PM
Digits?
 
is not
 
Specifically, we need to exclude only "spacing, (capitalisation,) and punctuation", apparently leaving everything else be.
 
then we need a list of the punctuation characters. I couldn't find such a list, thats why I choose to do it the other way around
 
Aha, but there's a trick.
 
sure :)
 
ovs
3:24 PM
≡⍥({⍵[⍋⍵]}⍤⎕C'\P{L}'⎕R'') includes all(?) letters
 
Very good. That's what I had in mind. No need for braces in {L} though.
Unicode classifies characters. The L class is Letters. \P negates that, to remove (replace by '') any non-letters.
Similarly, there's M for spacing Marks, Z for whitespace Zeparators(!), and P for Punctuation.
 
How is that different? It also looks at everything but the Letters, or do I misunderstand it?
 
So we can use '[\pM\pZ\pP]'⎕R'' to remove any spacing/whitespace (that'd probably cover the problem's "spacing") and punctuation.
 
(I didn't learn ⎕R yet, so that might be the problem)
 
@Richard Compare: ⋄ '\PL'⎕R''⊢⎕AV and (⋄ '---')⋄ '[\pM\pZ\pP]'⎕R''⊢⎕AV
 
3:29 PM
@Adám


ɫabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZýÁÂÃÇÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝþãìðòõÀÄÅÆÉÑÖØÜßàáâäåæçèéêëíîïñóôöøùúûü
---


	⌶ɫ⍺⍵abcdefghijklmnopqrstuvwxyz¯⍬0123456789⊢¥$£¢∆ABCDEFGHIJKLMNOPQRSTUVWXYZý⍙ÁÂÃÇÈÊËÌÍÎÏÐÒÓÔÕÙÚÛÝþãìðòõ€⊣⌷¨ÀÄÅÆ⍨ÉÑÖØÜßàáâäåæçèéêëíîïñ⌿⍀<≤=≥>≠∨∧+÷×∊⍴~↑↓⍳○∇∘⊂⊃∩∪⊥⊤|⍱⍲⍒⍋⍉⌽⊖⍟⌹⍕⍎⍫⍪≡≢óôöø´┘┐┌└┼─├┤┴┬│ùúû^ü`∣⍷⋄←→⍝⎕⍞⍣
 
Before the --- we have only strictly letters (and control chars). After the --- we have also various symbols and digits.
We'd need the latter to decide if '⍪⍨ + ⍪' and '⍪+⍪⍨' are anagrams.
@ovs Nice that you're using the sorting idiom instead of ≡⍥({⎕C⍵[⍋⍵]}'\P{L}'⎕R'')
Using {⍵[⍋⍵]} instead of a modification of it, makes for much faster sorting.
 
ovs
@Adám You have to case-fold before sorting, but yeah I also thought about the idiom
 
Why do I keep forgetting that‽
So ≡⍥({⍵[⍋⍵]}⍤⎕C'[\pM\pZ\pP]'⎕R'') would be the industrial/strict interpretation solution.
⎕C is also strictly speaking better than 1⎕C as the former is real case folding while the latter is case mapping. Case folding is intended for case-insensitive comparison (like we are doing here) while mapping is for human presentation forms.
E.g. it is true that 'ß'≡⍥⎕C'ẞ' but not 'ß'≡⍥(1∘⎕C)'ẞ'
Same with vs Å or å
However, even ⎕C won't handle vs á. Check out ⋄ ≢¨'á' 'á'
 
@Adám 2 1
 
Maybe we'll add support for full Unicode normalisation one day.
Anyway, I think we've exhausted this one, no?
 
3:43 PM
⍋⊃¨⊂ looks like a squirrel holding a spear :)
 
A chipmunk, but yeah.
Yawning chipmunk: ⊃⍥⊂
Pouting chipmunk: ⊃⍤⊂
Kissing chipmunk: ⊃⍣⊂
I should see myself out. See you next week for 2015-2: Longest Streak!
 
Thanks Adám!
 
next week!
 
 
6 hours later…
9:44 PM
Happy 2015! I meant to post earlier. I had {≡/{(⍋⊃¨⊂)∘(∊∘(819⌶⎕A){⍺/⍵}⊢)819⌶⍵}¨⍺⍵}
This was for Dyalog 17. Obvious modifications would shorten it in 2018.
 

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