« first day (2046 days earlier)      last day (601 days later) » 

4:55 AM
0
Q: Why is my APL expression returning 1 2 1 2 instead of 0 1 0 1?

ConnorMy expression (1 2 × 4) ⍴2 Is returning 1 1 1 2 2 1 1 2 1 1 1 1 1 1 2 2 2 2 1 1 2 1 1 2 1 1 2 1 1 1 2 2 but I expected it to return 1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 1 0 1 Why?

 
5:45 AM
-1
Q: What does enclose do in APL?

ConnorI have this array which is called x x 0 0 1 0 1 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 Supposedly something is happening when I enclose x using ⊂x but I see no difference: ⊂x 0 0 1 0 1 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 0 0 1 What's going...

 
6:29 AM
@user4996938 Hi Daniel K. If you want to participate here, simply email access@apl.chat
 
 
9 hours later…
3:00 PM
Welcome to APL Quest 2016-1! Today's quest is Statistics - Mean:
> Write a function that takes a numeric array as its right argument and returns the mean (average) of the array.
 
lol
 
Yeah, this should be quick.
 
⍉(+/÷≢)⍤1⍉
 
+⌿÷1⌈≢
 
Doesnt work for ⍬ (my solution)
 
3:01 PM
I have a feeling the problem asks to consider all elements in an array of any rank.
Nope, it doesn't.
@Adám Nope, see the last couple of examples.
 
Did I make it too complex? Does rak's solution work on array's etc?
 
yeah think so
 
Silly, :)
Maybe because I just learned ⍤ and was happy to find a purpose for it
And found the obvious solution too obvious
 
+⌿⊢÷≢ works too instead of 1⌈
 
≢∘⍸÷≢
⊢⌹=⍨
 
3:10 PM
@awagga :)
 
@rak1507 That's clever. Never seen it before.
@awagga How does the first one work?
Oh, I get it now. Only non-negative int vecs, though.
 
Both of these have issues, obligatory mentions I thought
 
This passes all test cases: ⌹⍤0∘(1∘⌈)⍥(1∘⊥)∘(=⍨)⍨
 
And how about mixed inputs, like (1 2) (3 3 ⍴ ⍳9), or is that just looking for problems
 
@Adám Looks pretty
 
3:17 PM
@Richard The average of that isn't really defined.
 
no, that's true, and can also use ¨
 
Here we go; an average function that uses none of rak's primitives: ⌹⍤0∘(0∘=--)⍥(1∘⊥)∘(=⍨)⍨
 
What is 1⊥ doing?
 
Summing.
 
:)
 
3:20 PM
Because (a,b,c)₁ = a×1² + b×1¹ + c×1⁰ = a×1 + b×1 + c×1 = a + b + c
One could argue that has ÷ in it…
×⍣¯1⍨∘(0∘=--)⍥(1∘⊥)∘(=⍨)⍨ then.
 
yes I understood, thanks!
And what about the ⍨ on the most right? What is it working on?
 
Everything else. The whole thing is one giant derived function (not a train).
However, 0∘=-- is a train, but we can get rid of it with ×⍣¯1⍨∘(-∘-∘(0∘=)⍨)⍥(1∘⊥)∘(=⍨)⍨
Outsourcing FTW: {⍬≡⍵:0 ⋄ ⍉mean⍤1⍉⍵⊣'mean'⎕CY'dfns'}
 
production solution :)
 
OK, have we beating this to death, yet?
 
thanks!
 
3:33 PM
See you next week for 2016-2: Statistics - Median.
 
 
2 hours later…
5:05 PM
I noticed that there is no APL solution in RosettaCode for Base64 encode/decode. I have my own implementation of them that I quickly rolled out, but I'm sure the community has better solutions. Curious if anyone has nice Base64 encode/decode code, and secondly, could someone fluent in J tell me if those J solutions are really complete?
https://rosettacode.org/wiki/Base64_decode_data#J
https://rosettacode.org/wiki/Base64_encode_data#J
 Base64Encode←{
 ⍝ ⍵ ←→ Text to encode
 ⍝ ← ←→ Base64 encoded text
     b←∊(8⍴2)∘⊤¨⎕UCS ⍵
     PadDelta←{⍵-⍨⍺×⌈⍵÷⍺}
     Pad←{d x←⍺ ⋄ ⍵,(d PadDelta≢⍵)⍴x}
     p←{⍵⊂⍨(≢⍵)⍴6↑1}6 0 Pad b
     t←⎕A,⎕C ⎕A,⎕D,'+/'
     4 '='Pad t[⎕IO+2⊥¨p]
 }
 Base64Decode←{
 ⍝ ⍵ ←→ Base64 encoded text
 ⍝ ← ←→ Original text
     t←⎕A,⎕C ⎕A,⎕D,'+/'
     i←(t⍳⍵)-⎕IO
     b←∊(6⍴2)∘⊤¨i
     p←{⍵⊂⍨(≢⍵)⍴8↑1}b
     XPadding←⍵∘{⍵↓⍨-+/∧\⌽'='=⍺}
     ⎕UCS 2⊥¨XPadding p
 }
The J solutions:
BASE64=: (a.{~ ,(a.i.'Aa') +/i.26),'0123456789+/'

frombase64=: {{
  pad=. _2 >. (y i. '=') - #y
  pad }. a. {~ #. _8 [\ , (6#2) #: BASE64 i. y
}}
   tobase64 =:  padB64~ b2B64
     padB64 =:  , '=' #~ 0 2 1 i. 3 | #
     b2B64  =:  BASE64 {~ _6 #.\ (8#2) ,@:#: a.&i.
here is the base64 solution in dfns.dyalog.com :
base64←{⎕IO ⎕ML←0 1             ⍝ Base64 encoding and decoding as used in MIME.

    chars←'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
    bits←{,⍉(⍺⍴2)⊤⍵}                   ⍝ encode each element of ⍵ in ⍺ bits,
                                       ⍝   and catenate them all together
    part←{((⍴⍵)⍴⍺↑1)⊂⍵}                ⍝ partition ⍵ into chunks of length ⍺

    0=2|⎕DR ⍵:2∘⊥∘(8∘↑)¨8 part{(-8|⍴⍵)↓⍵}6 bits{(⍵≠64)/⍵}chars⍳⍵
                                       ⍝ decode a string into octets
 
5:31 PM
@Adám @Adám basically I'm using Wayland instead of X11, which doesn't work with RIDE (as you may know already: github.com/Dyalog/ride/issues/879). In any case I'm moving to a much more text heavy workflow to minimise distractions b.c. my relationship to time is fragmentary b.c. my employment situation is poor/precarious.
 
 
1 hour later…
6:45 PM
@JoshD I have some BQN Base64 implementations here. They don't look hard to translate.
The J versions aren't obviously missing anything, but they split the argument completely into bits, which is bound to be pretty slow.
Actually it does seem that J tobase64 drops a bit or two when the argument length isn't a multiple of 3.
 
7:04 PM
@Marshall Interesting, thanks!
yeah the J versions seemed a little too good to be "complete"
 
7:27 PM
∊(8⍴2)∘⊤¨⎕UCS ⍵ -> ,⍉(8⍴2)⊤⎕UCS ⍵
 

« first day (2046 days earlier)      last day (601 days later) »