« first day (1737 days earlier)      last day (918 days later) » 
00:00 - 21:0021:00 - 00:00

9:00 PM
wait ok
i think i am maybe figuring it out
how do i turn a char vector into a hexadecimal number
 
@gamma_delta You mean represent each byte as to hex digits?
 
I think so?
#.Crypt.HASH_MD5 #.Crypt.Hash'test'
this gave me a string, looks like?
 
Convert chars to code points, then convert to hexadecimal, e.g. using the hex function from dfns.dws
 
oh yeah what is dfns
i've heard about that
 
Or actually, you could just implement it yourself: ⎕←(⎕D,⎕A)[¯1+,⍉16 16⊤⎕UCS'hello']
 
9:03 PM
@Adám 46434A4A4D
 
Huh
 
@gamma_delta It is a workspace (binary blob) that has a ton of useful things implemented as dfns.
 
⎕←↓⍉{(⎕D,⎕A)[1+16⊥⍣¯1⊢⍵]}⎕UCS'hello'
 
@awagga
┌──┬──┬──┬──┬──┐
│68│65│6C│6C│6F│
└──┴──┴──┴──┴──┘
 
Beat me to it
 
9:04 PM
@awagga That's dangerous.
 
What does ⎕D and ⎕A and ⎕UCS and all mean
 
You know you can look them up with F1 and on APLcart?
 
Huh
 
⎕D is '123456789', ⎕A is the same but letters and ⎕UCS converts letters to ascii codes
 
… and vice versa.
 
9:05 PM
Huh
 
@Adám It is?
 
Also, ⎕D has a 0 :-)
 
Darn, my memory has failed me
 
Hexify← {(⎕D,⎕A)[¯1+,⍉16 16⊤⎕UCS⍵]} didn't seem to work
 
@awagga Yes: ⎕←↓⍉{(⎕D,⎕A)[1+16⊥⍣¯1⊢⍵]}⎕UCS ⎕JSON'"\u000a\u000c"'
 
9:07 PM
@Adám
┌─┬─┐
│A│C│
└─┴─┘
 
Hexify 'AAAABBBB' gives me an index error
 
Ah, I see
 
@gamma_delta My bad: remove the ¯
 
aha nice
and this yields a string?
or, char vector
 
"string"s are char vecs.
 
9:11 PM
ok it seems to be working
hm. ok. this seems like a case where it's good to use an actual iterator and not a loop. or like a long-form dfn
 
@gamma_delta Yay, care to share?
 
```
⍝ Thanks, Adam, i'm not going to pretend I know how any of this works
MD5 ← {(⎕D,⎕A)[1+,⍉16 16⊤⎕UCS(#.Crypt.HASH_MD5 #.Crypt.Hash ⍵)]}
```
 
⎕CY'dfns' to use hex btw
{hex ⎕UCS(#.Crypt.HASH_MD5 #.Crypt.Hash ⍵)}
I don't think you need those brackets either
 
@gamma_delta Remove the backticks and press Ctrl+k.
 
⍝ Thanks, Adam, i'm not going to pretend I know how any of this works
MD5 ← {(⎕D,⎕A)[1+,⍉16 16⊤⎕UCS(#.Crypt.HASH_MD5 #.Crypt.Hash ⍵)]}
 
9:16 PM
@awagga Might want to 'hex'⎕CY'dfns' so as not to clutter.
 
Oh, I didn't know you could import a single function, cool.
 
You can import multiple with multiple names on the left too.
 
Good to know ^^
 
MineThreshold ← {
    thresh ← ⍵
    recur ← {
        ⍝ ⍵ = the key we're trying in here
        hash ← MD5 input , ⍕⍵
        ∧/'0'=thresh↑hash : ⍵
        ∇ 1+⍵
    }
    recur 1
}
let's see
 
9:19 PM
@gamma_delta My colleague Brian says you just need echo -n to avoid the newline.
 
Aha but that doesn't work on windows
it works on linux but not windows
 
@gamma_delta Please use Ctrl+k (you can still edit!)
 
What does ctrl+K do and it said it was too late to edi tit
im very confused
 
It adds 4 spaces to each line, causing chat to show it as code.
@gamma_delta You get a VALUE ERROR?
 
@Adám echo -n test dutifly prints out "-n test\n"
(dutyfly?)
(Obligatorily and stupidly)
 
9:21 PM
@gamma_delta Sure, but if you pipe it into md5sum?
 
Yeah it still pipes it
oh well it's working with the library now
 
@gamma_delta Not by me. Wait, Windows?
@gamma_delta Good. That's probably also faster than shelling out a bunch of times.
 
Yeah ... ⎕SH will use the windows command processor
bypassing cygwin and it's copy of echo that actually works
 
Ah, right, then -n doesn't work.
 
Anyways more fun problems, i'm getting a syntax error at the newline on the MineThreshold ← { line
i already resaved the file as LF and not CRLF
 
9:25 PM
@gamma_delta Did you switch on multi-line mode?
 
uh i don't know
i want all my final solutions to be runnable from .dyalog scripts
 
@gamma_delta Huh, apparently, under Windows, you need echo | set /p= to echo without a newline. Because Microsoft.
 
for posterity or something
 
@gamma_delta Set the config param DYALOG_LINEEDITOR_MODE=1
 
how does one do that
 
9:28 PM
You can do so in the registry, a config file, as a dyalog argument, an environment variable, or a command line parameter.
 
will it auto-load the config file?
 
Depends a bit on how you are running stuff.
How do you run your .dyalog script?
 
dyalog -script day04.dyalog
 
So just add DYALOG_LINEEDITOR_MODE=1 to that.
 
so i have to retype it everytime? ugh. ok
 
9:31 PM
Then set it as an environment variable. Are you running this under cygwin or straight under Windows?
 
wsl actually, cause the dyalog that goes on windows won't run -script files
(Didn't we talk about this)
 
Oh. then yeah, just set the variable permanently.
 
YEAH it works
nice
Is there a nice clean way to run a couple functions on the same input, then check if they all returned 1?
like some kind of ∧/ that maps over function calls?
my brain tells me some kind of cool . usage but i dont know
 
You could express it as a train: ∧/(f,g,h)input
 
or (f∧g∧h)input
 
9:42 PM
Ninja'd.
 
Ohh i see(?)
you like stitch together (F calls) (G calls) (H calls) (I calls) ... and then check all of them?
 
Yeah.
 
God someday I'll remember this. but uh for now how might i check how many vowels are in a string?
i forget the function for that
like i need to +/ over something
 
⎕←(×∧(⊢≡⌽)∧((⌊=⊢)*∘0.5))121
 
@awagga 1
 
9:47 PM
Checks if a number is a palindromic square, ×∧ is useless here, but you get the idea
 
@gamma_delta you could use ≢ and ∩ (intersect)
but +/ and checking if it's in the string would work too
 
@gamma_delta +/string∊vowels
 
thank you
 
10:08 PM
hi, i am going to ask a very XY question, but i'm asking it because i'm asking for help on an algorithm i made up, i don't want a "good" algorithm cause then i'm not learning anything, right
So i need to see if a string has doubled letters in it. So far I have {⍺(2-/⍵)}⌸ 'aabcca'
the objective being, if there's any ¯1s in there, the letter is doubled
Problem is I have no clue how i might filter this
 
oh, clever
that's actually a cool method!
 
I have a question @gamma_delta why ddo you have the ⍺ in the function?
 
@Miguel sure?
So I know what the letter is later
c-- oh
 
⎕←¯1∊¨↓{(2-/⍵)}⌸ 'aabcca'
 
@awagga 1 0 1
 
10:11 PM
oh that's a good point
 
@gamma_delta ⎕←∊{⊂⍺/⍨1+¯1∊(2-/⍵)}⌸ 'aabcca'
 
@Adám aabcc
 
¯1∊{2-/⍵}⌸
I don't need to know what the letters are just that they're there
i bet i can make this the coolest train you've ever seen hold on
 
Oh, you just need to know if any adjacent letters are identical?
That'd be ⎕←∨/{¯1∊2-/⍵}⌸ 'aabcca'
 
@Adám 1
 
10:14 PM
(¯1∘∊{2-/⍵}⌸)
that's my solution
 
No need for
 
woah did i outgolf you
 
⎕←(¯1∊2-/⊢⌸) 'aabcca'
 
@awagga 1
 
Few people can outgolf Adám :P
 
10:15 PM
@gamma_delta Yeah, I didn't think of the fact that the mixed result's 0s don't matter.
Revenge: ⎕←∨/2=/'aabcca'
 
@Adám 1
 
Well then
oh god that's way smarter than i
need to check for double letters? just check for double letters
 
Yup.
 
Alright, so i have a question
 
Go for it!
 
10:18 PM
I've been trying to make a fibonnacci function, you give it a list starting with 2 fibonnacci numbers (like ⍳10) and the starting position for it to continue the sequence
 
@gamma_delta Now, how would you check for triple letters? stresssyndrome → 1 stress syndromess → 0
 
So the list is defined in the environment and the number is a parameter
 
@Miguel And then it has to replace elements after the starting position?
 
i got up to here
FIB ← {
⍵>≢V:V
V[⍵]←V[⍵-1]+V[⍵-2] ⋄ ∇ ⍵+1
}
 
@Miguel Put your code in a separate message, and press Ctrl+K before posting it.
 
10:20 PM
And it works but whenever i try to make V into ⍺ it break
@Adám yes, sorry
 
FIB ← {
    ⍵>≢⍺:⍺
    ⍺[⍵]←⍺[⍵-1]+⍺[⍵-2] ⋄ ⍺ ∇ ⍵+1
}
Like this?
My guess is that you missed the before
 
@Adám Yes
No no, i did put it in there
 
Can you give us values for V and the argument that work as you want?
 
V ← ⍳10
 
I'm getting a domain error, somewhere
is there a way to pick apart where
 
10:24 PM
so you would call it like
V FIB 3
 
@Miguel Oh, I see the problem. You're not allowed to change the value of
@gamma_delta Sure, but you'd want to run in the interactive session rather than with a script, then.
However, yes, you can set ⎕TRAP←0'E' '⎕←↑⎕DM at the top of your script.
 
@Adám huh, alright. Then follow up, how could you make it work
 
@Miguel Just use x←⍺ and modify x
Alternatively, you can use @ to change the value and give the result to :
FIB←{
    ⍵>≢⍺:⍺
    ((⍺[⍵-1]+⍺[⍵-2])@⍵⊢⍺) ∇ ⍵+1
}
@Miguel Btw, check out +/⍺[⍵-1 2]
 
How do you filter for non-empty lines?
or like non-empty strings
 
Filter by 0≠≢¨
⎕←{⍵/⍨0≠≢¨⍵}'Hello' '' 'how' '' '' 'are' 'you?'
 
10:31 PM
@Adám
┌─────┬───┬───┬────┐
│Hello│how│are│you?│
└─────┴───┴───┴────┘
 
god i'm so stupid i was like "why isn't this working"
it was because i was reading day05.dyalog and not day05.txt
 
:-)
 
Given an array of strings, how can i tell how many times each of those strings appears in another string?
i would need ... ⍷ and +/ i think
 
@Adám is ⍵⊢⍺ a special case? shouldn't it just be ⍺
 
@gamma_delta Yeah, strings+/⍤⍷¨⊂string
Many variations are possible.
 
10:42 PM
Specifically i'm trying to figure out if the string contains any letter pairs twice (or more)
(2,/case)+/⍤⍷¨case is giving me a length error?
 
@Miguel It isn't ⍵⊢⍺ it is ⊢⍺. The is bound by @ because @ is a dyadic operator.
@gamma_delta You're missing before case
 
{2,/⍵} 'alphabetic'
hey
⎕←2,/ 'alphabetic'
 
@gamma_delta
┌──┬──┬──┬──┬──┬──┬──┬──┬──┐
│al│lp│ph│ha│ab│be│et│ti│ic│
└──┴──┴──┴──┴──┴──┴──┴──┴──┘
 
but isn't ⊢ dyadic aswell?
 
aha
 
10:44 PM
@gamma_delta When you forget ⎕← you can just edit it in, and the bot picks up the change.
 
Oh ok
 
@Miguel It is, but so are many functions. Here, it is used monadically.
 
@Adám Alright, let me explain what i understand from the line
((⍺[⍵-1]+⍺[⍵-2])@⍵⊢⍺)
(⍺[⍵-1]+⍺[⍵-2])
                            ⍵⊢⍺
(⍺[⍵-1]+⍺[⍵-2])@⍵⊢⍺
 
No, that's wrong. @ is not a function, but a dyadic operator.
It needs at least a left operand (⍺[⍵-1]+⍺[⍵-2]) and a right operand and an argument ⊢⍺
The is necessary to prevent ⍵ ⍺ from being a 2-element vector.
 
Hm. how might i do this problem making sure that 'aaa' doesn't count?
 
10:48 PM
You could also write it as …)@⍵)⍺
@gamma_delta Not sure what you mean.
 
So we've been solving the problem "See if this string has any pairs of letters more than once"
the problem is our solution would match "aaa"
This is against the problem statement, they're not allowed to overlap
 
Ah, so you don't want it to be counted as aa twice?
 
"aaaa" would work but not "aaa" yeah
 
That'll be bit more complicated. The easiest way is to use regex.
 
Lovely
that would be like /(\w\w).*\1/?
 
10:51 PM
@Adám Now it makes sense, thanks!
 
@gamma_delta I'd use '(.)\1' if I understand the problem right.
 
I plugged my soln into regex101 and it seems to work
 
In APL, regexes are not a type, they are just normal character vectors.
 
I dont think you understand the problem then... uh
> [The string passes if] It contains a pair of any two letters that appears at least twice in the string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps).
 
@gamma_delta Oh, OK, you're looking to see if the same double-letter occurs twice.
 
10:52 PM
Yep
Regex my beloved
 
Then your regex is correct, yes.
⎕←(≢'(\w\w).*\1'⎕S 3)¨'xyxy' 'aabcdefgaa' 'aaa'
 
@Adám 1 1 0
 
@Adám So, i've tried the sum reduction and got FIB looking like this:
FIB ← {
     ⍵>≢⍺:⍺
     ((+/⍺[⍵-1 2])@⍵⊢⍺)∇ ⍵+1
 }
 
That looks pretty nice.
 
Thanks for the help! i'm really grateful of having a pro guiding me
 
10:58 PM
Happy I could help. That's what I'm here for.
 
Idk why but there's something satisfying in APL code
 
very true
 
tomorrow i'll finish the ProjectEuler problem
 
@Miguel Yes, it is hard to put a finger on what exactly it is, but people keep coming back for more.
 
:)
 
11:00 PM
stumbled across a syserror 999 - searched it here, and found I had the same issue a while ago haha
 
Alright everyone, have a nice one, i'm off to sleep
 
@rak1507 But you still can't reliably repro? Did you at least get an aplcore?
 
@Adám no, I can, it's the 8415⌶ one
 
Oh, I never realized there was a search bar in the top right
 
@rak1507 Hm, yeah I see my colleagues could repro it.
 
11:03 PM
@Adám interesting
 
oh btw @xpqz really liking the book, I found it a little overwhelming on the Indexing chapter
 
I bookmarked the Dyadic Transpose, Indexing + Rank page, they're worth referencing if you get stuck whilst learning :)
 
Speaking of @xpqz I've finally caught up a bit with my to-do list. Reviewing your blog post might just be the next thing…
 
11:32 PM
Given the four corners of a box how might i select it in a way i could do ← on it?
or like .... this is a problem i'm not especially sure how to use apl with
I have a list of commands that are ways to update areas in a grid
 
Well, do you have the size of the box?
@hypumji Welcome. Interested in APL?
 
uh, the commands are in the form 887,9 through 959,629
and the total grid is 1000x1000
⍳1000 ∘.0⍨ ⍳1000 yes?
⎕← ⍳10 ∘.0⍨ ⍳10
 
@gamma_delta
SYNTAX ERROR
      ⎕←⍳10∘0⍨⍳10
          ∧
 
That doesn't look right. Not sure what you;re trying to do.
Did you mean = instead of 0?
 
∘. is cartesian product right?
Oh im so dumb
literally
⎕←10 10⍴0
 
11:35 PM
@gamma_delta
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
 
except with 1000
 
OK. So now you need to parse the commands and update the "canvas"?
 
Yeah
Once i have the region and can mutate it, that should be pretty easy fortunately
cause all i need to do is turn on, turn off, or toggle (~)
 
That should be easy, yes. What's the problem? Selecting the right regions?
 
I could do it with some kind of like, multi-line dfun where i make a board and keep mutating it with ← as i ¨ over each line
I just want to know how I can select a region of a board in a ←-able way
cause i should be able to use modified assignment yes
 
11:38 PM
You could use selective or indexed assignment.
E.g. (params⌷canvas)←1 and canvas[params]←1
 
@gamma_delta Have you solved any problems.tryapl.org?
 
I suspect they may be of a more appropriate level for you, so you can get some experience you can then apply to harder things like Project Euler.
 
aha assigning to compress each
no that's a terrible idea
 
11:59 PM
tAKES AND DROPS
yess
 
00:00 - 21:0021:00 - 00:00

« first day (1737 days earlier)      last day (918 days later) »