« first day (1857 days earlier)      last day (780 days later) » 

2:50 AM
@rabbitgrowth @Adám thanks for the alternatives!
 
 
4 hours later…
7:18 AM
@RGS MDAPL on Hacker News: news.ycombinator.com/item?id=30453919
 
 
5 hours later…
11:48 AM
              ang 1 4
        1.325817664


              parc 1 4
        1 4

              ⎕SE.Dyalog.Utils.repObj parc 1 4
        1 2⍴1 4

              ang/parc 1 4
        0.7853981634

              ⎕SE.Dyalog.Utils.repObj +/parc 2 4
        ,6

    my ang  function breaks when i do ang/parc 1 4. i did some tests and i have no idea why.

    if you want the full spesific function then:
    ang←12○1 0J1+.×⊢
   parc←(2,⍨(≢1↓⊢))⍴1↓2/⊢
i should maybe specify the problem. ang 1 4 gives the right answer which is 1.32... but when used after parce it gives 0.785 which is wrong
 
notice:
      ang←12○1 0J1+.×⊢
      ang 1 4
1.325817664
      1 ang 4
0.7853981634
 
wait...
ahhhhhhhhhhhh
i get it now
thanks
 
 
1 hour later…
1:08 PM
i'd like to inquire about implementing an apl interpreter (specifically, in an array language).
I know of marshall's apl seeds chatlogs so far
 
@Razetime There are some interesting fragments in dfns, e.g. dfns.dyalog.com/n_parse.htm
An APL interpreter in BQN?
 
that would be ... interesting
 
> Some of the notes in this workspace contain sections that are merely the musings
of the author. They may not be entirely factual and you should check the content
with a reliable source (Wikipedia) before repeating them to a discerning audi-
ence.
something doesn't sound right.
 
@xpqz if you remember the xbox achievement "back to the roots", that is what i will be doing :)
 
1:17 PM
lol
 
i see the funny part :)
 
Many years ago, as my university final year project, I wrote a Prolog interpreter in SmallTalk, because why not.
 
APL interpreter in APL: ⍎
 
oooo true
@Adám how in the world can index origin be 0.5???
 
@BrianBED its a joke
 
1:30 PM
ahhh right makes sense... looked like it
 
ok im currently making an array language (in my brain of course)
here what i came up with to store the arrays:
typedef struct {
  unsigned rank;
  unsigned *shape;
  int *data;  /* will change to a tagged union */
} array;
 
im wondering how would i implement, say, reverse with the way im planning to store the elements ...
 
@PyGamer0 how about strided representation?
 
@KamilaSzewczyk wdym
soo something like a linked list?
 
1:37 PM
19
Q: What is a strided array?

ThomsonThere is also a counterpart which is called density array. What does this mean? I have done some search, but didn't get accurate information.

 
so the array elements are not located continuously in memory?
a | junk | b?
 
There was a good paper on NumPy's strided array implementation a while back, but I can't seem to find it with a quick google.
 
@xpqz ah gr8
 
where was RGS's implementing APL blog again?
 
1:53 PM
@RikedyP pronounce double-struck x as "strex"
 
double struck w?
strew
 
strew is funny but probably stredouble-u
 
seems like i am thinking of the same way as RGS implemented to represent my arrays
unfortunately RGS didnt implement so i cant yoink it
 
The one I was thinking of was deep-diving the c implementation.
 
i think i understand strides
 
I just realized that ⌽ ⊖ ⍉ is + `| - \`
For some reason I never noticed
 
@rabbitgrowth - That's actually how those characters were input on early APL-capable terminals.
 
So you type , immediately followed by |? Or would you have to combine the characters somehow?
 
2:26 PM
, Backspace, |
 
@rabbitgrowth press backspace
 
Backspace
 
It still works: ⋄ ⎕FMT'○',(⎕UCS 8),'|'
 
@Adám
 
@Adám - Does Dyalog support overstriking, or just the direct entry of the precomposed characters?
 
2:28 PM
It does support overstriking, but not all the combos APL\360 did.
E.g. You can't overstrike F and L to make E
 
!! I wasn
I wasn't aware that those were allowed on the 360...
 
Announcement: APL Quest 2013-4 in half an hour.
 
oh i forgot about that
 
Would you just see | on the screen? Obviously on a typewriter you would see
 
I have a clash for today's Quest, will watch on catchup-tv
 
2:30 PM
I just assumed that the only overstrikes that APL\360 allowed were the functional overstrikes.
 
@rabbitgrowth What screen?
 
@Adám I prepared some solutions. Really curious for this one!
 
@rabbitgrowth - On the APL-capable 3270, it would show the overstruck character,
 
Interesting
 
Yeah, the overstrikes were always part of the character set. Overstriking was an input method.
 
2:33 PM
/me is reminded that now that he's found his copy of Wiedmann, he should work on doing a Dyalog version ... in his copious spare time... :þ
 
I knew that ⍞⍠⌸⌺ are + ':=⋄, but failed to notice the same about ⌽⊖⍉
I also prepared a solution for the Quest. Really looking forward to this one :)
> APL\360 supported many overstrikes, and these were the only way to type composite glyphs. Since typewriters couldn't remove typed characters, editing could be cumbersome, and so some innovative overstrikes were allowed for the odd case where one was correcting a typographical error. For example, F and L would form E.
I love this so much
 
Very interested to see a golfed solution, balancing tokens is a common problem for me and my solution is quite verbose
 
i don't think it's possible to solve this problem in an elegant way which doesn't involve the traditional scan sum+index solution.
best i can think of is expanding the bracket indexing into ⌷⍨⍤1 0 which sucks.
 
@KamilaSzewczyk Index‽
 
tempting to reveal my solution I came up with on spot :P
 
2:47 PM
Hold it for 13 mins!
 
+\1 ¯1 0['()'⍳⍵] is an APL idiom already, isn't it?
 
Not in my opinion.
 
fascinating
i see you use a fork with comparisons on APLCart
doesn't seem elegant whatsoever compared to what i posted
 
"My" solution is actually something Dzaima wrote for me a few months ago that I haven't been able to improve :P
 
@KamilaSzewczyk They are not the same:
      a↑⍤,⍥⊂{+\1 ¯1 0['()'⍳⍵]}a←'((2×3)+4)'
( ( 2 × 3 ) + 4 )
1 2 2 2 2 1 1 1 0
      a↑⍤,⍥⊂(+\'('∘=-¯1↓0,')'∘=)a←'((2×3)+4)'
( ( 2 × 3 ) + 4 )
1 2 2 2 2 2 1 1 1
 
2:50 PM
exciting
i'm currently a bit occupied so i'll just post my solutions when the event starts and then head out
 
my solution domain errors lmao
 
"solution"
 
lol
 
fairly sure they don't contribute too much anyway since they use the old trick from above and a hefty fork to make it work
 
i made the worst APL function ever
 
2:55 PM
Oh, not you didn't. I'm sure I've written something worse ;-)
 
it works though but it looks like spaghetti
 
Welcome to the APL Quest! Today's quest is Keeping Things In Balance:
> Write an APL dfn which returns a 1 if the opening and closing parentheses in a character vector are balanced, or a zero otherwise.
Feel free to post your solution(s).
 
{p←-⌿'()'∘.=⍵ ⋄ (0=+/p)∧(∧/0≤+\p)}
 
My attempt: ((0∧.≤+\)∧0=+/)(-⌿'()'∘.=⊢)
 
((¯1∊+\) ⍱ 0≠+/) '('∘= - ')'∘=
 
3:00 PM
yall solutions are actually good
here is mine
 
@BojanPetrović Put backticks (`) around your code.
 
{⍺←0⋄''≡⍵:0=⍺⋄(0=⍺)∧')'=⊃⍵:0⋄'('=⊃⍵:(⍺+1)∇1↓⍵⋄')'=⊃⍵:(⍺-1)∇1↓⍵⋄⍺∇1↓⍵}
 
Oh, sorry!
And here's one that's neither golfed, nor fast, it just... is :)
{2::0⋄6::1⋄(⍎'{} '['()'⍳⍵])⍣0⊢1}
 
@BojanPetrović You can still fix it. Press UpArrow to edit previous messages.
 
and a general one for different parentheses
{p←{+⌿⍵}⌺(⍪2 2)(-@(2×⍳2÷⍨≢⍺))⍺∘.=⍵ ⋄ ∧/(0=+/p)∧(∧/0≤+\p)}
 
3:02 PM
i dont know what recursive mess i made
 
{((∧/0≤+)∧0=+/)-⌿'()'∘.=⍵}
 
Nice!
 
@FawnLocke Nice!
 
We have a couple of solutions that repeat 0. Maybe we can combine parts to use a single zero?
 
  h←((∧/≥∘0∧0=⊃∘⌽)+\∘(1 ¯1 0⌷⍨⍤1 0('()'∘⍳)))
  f←{(∧/≥∘0∧0=⊃∘⌽)+\1 ¯1 0⌷⍨⍤1 0⊢'()'⍳⍵}
  g←{(∧/≥∘0∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
 
3:05 PM
@FawnLocke Does this work on '(()_)_'?
 
Should do
 
Shouldn't that be 1?
 
additionally:
 
That's what it gives me
 
      f←{+\-⌿'()'∘.=⍵}
      g←{+\1 ¯1 0['()'⍳⍵]}
      cmpx 'f t' 'g t'
  f t → 6.4E¯4 |  0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 5.9E¯4 | -7% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
3:07 PM
@BojanPetrović a variation on that: {0::0⋄⊃⍎⍕1,1,¨⍵∩'()'}
 
@FawnLocke ⋄ {((∧/0≤+)∧0=+/)-⌿'()'∘.=⍵} '(()_)_'
 
@Adám 0
 
you can't solve this problem without a running sum
 
Oh, escaping
  {((∧/0≤+\)∧0=+/)-⌿'()'∘.=⍵}
 
because e.g. )...( is considered invalid according to the tryapl page
 
3:08 PM
@FawnLocke Ah.
 
@dzaima Cool, thanks!
 
Did anyone notice that +/ is the last element of +\?
 
you don't need to notice it if you solve it the way i did :)
 
I did, in the first solution i moved the +\ outside the fork and then indexed the last element, but I didn't see large speed improvements.
 
This is an earlier version: (∧.≥∘0∧0=⊃⍤⌽)(+\1 ¯1 0⌷⍨∘⊂'()'∘⍳)
 
3:11 PM
computing +/ would be completely redundant in my program and would ultimately lead to a slowdown because the running sum is computed anway
 
@KamilaSzewczyk Sorry, I intended to get to your solution. I didn't notice it.
 
@dzaima :) wow, looks impressive, but don't understand it
 
(For some reason, it fails with SYNTAX ERROR on the TryAPL page, but if I change the to , it works.)
 
@KamilaSzewczyk ∧/≥∘0∧0=⊃∘⌽∧.≥∘0∧0=⊃∘⌽ for efficiency.
 
good idea
 
3:13 PM
@Richard ⍵∩'()' removes all characters that aren't parentheses. 1,1,¨ adds some random 1s in it to make it valid syntax. formats it to a string, then evaluates it as APL code. If it errors, it's got mismatched parantheses as APL syntax doesn't allow that
 
Can't figure out how to avoid repeating 0
 
@dzaima chapeau
 
      f←{(∧/≥∘0∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
      g←{(∧.≥∘0∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
      cmpx 'f t' 'g t'
  f t → 8.9E¯4 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 1.4E¯3 | +56% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
"efficiency"
 
@dzaima That is very clever. Delegate to the APL parser.
@KamilaSzewczyk How large an argument?
 
ovs
@Adám {0(=∘⊃∘⌽∧∧.≤)+\-⌿'()'∘.=,⍵}
 
3:14 PM
1e6=≢t
 
Hm, that doesn't sound right. ∧.comparison should have potential to be much faster than ∧/comparison
 
i think my solution is the fastest so far.
@Adám derived functions in dfns are slow
 
But these Boolean ones should be optimised.
 
in general i noticed that inner product is weirdly slow in a lot of cases.
compared to reduction & map
      h←{(∧/(≥∘0)¨∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
      cmpx 'f t' 'g t' 'h t'
  f t → 1.3E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 1.6E¯3 | +24% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  h t → 1.3E¯3 |  +6% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
even that is faster somehow
 
Oh, I think ⊃∘⌽ is slow too.
 
3:18 PM
the two are different, ∧/ is at the end of f but the start of g
try (≥∘0∧.∧0=⊃∘⌽)
 
But it doesn't make sense to make n ∧s with 0=⊃∘⌽
 
true
 
      f←{(∧/≥∘0∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
      h←{(∧/≥∘0∧0=(⊃⌽⊢))+\1 ¯1 0['()'⍳⍵]}
      cmpx 'f t' 'h t'
  f t → 1.3E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  h t → 9.2E¯4 | -30% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
idiom power?
 
⊃⌽⊢ isn't ⊃∘⌽
 
oh ooops
 
3:20 PM
try ⊃⍤⌽ or ⊢/
 
⊢/ fails on empty.
 
:(
 
it's quite fast though
-40% for me
 
      f←{(∧/≥∘0∧0=⊃∘⌽)+\1 ¯1 0['()'⍳⍵]}
      h←{(∧/r≥0)∧0=⊃⌽r←+\1 ¯1 0['()'⍳⍵]}
  f⊢t → 2.1E¯3 |  0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  h⊢t → 2.0E¯3 | -5% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
i feel like assignments of this kind are really obscure.
 
3:23 PM
Really? That's just a normal variable for reuse of a value.
 
@Adám Could you post the definition of t?
 
they make me think of really old APL code.
 
t←'ab()'[?1e6⍴4]
 
forks already allow us to duplicate data.
my defn. of t is t←'()×123'[?1e5⍴6]
 
@ovs Use Ctrl+k instead of ```blocks
 
3:26 PM
this will fail for empty input
 
ovs
      t←'ab()'[?1e6⍴4]
      h←{(∧/r≥0)∧0=⊃⌽r←+\1 ¯1 0['()'⍳⍵]}
      g←{0(=∘⊃∘⌽∧∧/⍤≤)+\1 ¯1 0['()'⍳⍵]}
            ]runtime -c 'h t' 'g t'

  h t → 7.5E¯4 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 6.1E¯4 | -20% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
fixed ...
 
{⍺=⊃⌽⍵} or =∘{⊃⌽⍵} can be used instead of =∘(⊣/) to apply the idiom.
 
I tried to rebuild my solution so it can check also different parentheses. Maybe the other solutions are more suitable for that? (the stencil operator was a good suggestion from somebody else, so was the @)
'<>{}[]()'{p←{+⌿⍵}⌺(⍪2 2)(-@(2×⍳2÷⍨≢⍺))⍺∘.=⍵ ⋄ ∧/(0=+/p)∧(∧/0≤+\p)}'({}([[]])<>)'
 
i feel like my solution (or a variant of it) could be useful here
 
@Richard Fails on ([)]
I think multiple paren types requires a state machine.
 
3:30 PM
@Adám or group
 
@Adám ah, sht
 
@dzaima BQN's primitive?
 
      =∘(⊣/)∧∧/⍤≤
 ┌──┼─┐
 ∘  ∧ ⍤
┌┴┐  ┌┴┐
= ⊣/ / ≤
   ┌─┘
   ∧
Why is / shown next to but not next to ?
 
@rabbitgrowth Because ⊣/ is parsed as an idiom. Nice catch!
 
@Adám APLs is usable too
 
3:32 PM
You mean Key?
 
      f←{0(=∘⊃∘⌽∧∧/⍤≤)+\1 ¯1 0['()'⍳⍵]}
      g←{0=≢⍵:1⋄((∧/≥∘0)∧0=≢⊃⊢)+\1 ¯1 0['()'⍳⍵]}
      cmpx'f t' 'g t'
  f t → 2.0E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 1.5E¯3 | -23% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
@Adám yeah
 
and some kind of Regex solution?
 
      f←{0=≢⍵:1⋄((∧/≥∘0)∧0=≢⊃⊢)+\1 ¯1 0['()'⍳⍵]}
      g←{0=≢⍵:1⋄((∧/≥∘0)∧0=≢⊃⊢)+\('('=⍵)-')'=⍵}
      cmpx'f t' 'g t'
  f t → 1.6E¯3 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 1.3E¯3 | -22% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
@Richard ''≡'\(\)'⎕R''⍣≡⍤∩∘'()'
 
I like the symmetry of g, but unfortunately it is slower
      f ← {1 ¯1 0['()'⍳⍵]}
      g ← '('∘= - =∘')'
      ]runtime -c 'f t' 'g t'
  f t → 2.2E¯4 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 2.5E¯4 | +12% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
sorry, I'm having issues pasting
 
3:37 PM
@BojanPetrović Not the result I'm seeing:
      f←{-⌿'()'∘.=⍵}
      g←{1 ¯1 0['()'⍳⍵]}
      h←'('∘=-=∘')'
      cmpx 'f t' 'g t' 'h t'
  f t → 3.7E¯4 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  g t → 5.0E¯4 | +35% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
  h t → 1.9E¯4 | -50% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
 
ah, it's faster for me because 1 ¯1 0['()'⍳⍵] is much slower in whatever 18.2 version i'm running
 
Never mind, these are not the same.
 
⋄{∧/0(=∘⊃∘⌽∧∧/⍤≤)¨↓('()' '<>' '[]'){+\1 ¯1 0[(↑⍺)⍳⍵]}⍤0 1⊢⍵}'([)]'
no state machine
 
@KamilaSzewczyk 1
 
might stop working uncontrollably
 
3:38 PM
what is a state machine?
 
an automata that transitions between states.
 
Traversing the data sequentially, while updating a memory.
 
simpler perhaps: ⋄{∧/0(=∘⊃∘⌽∧∧/⍤≤)¨⍵∘{+\1 ¯1 0[⍺⍳⍨↑⍵]}¨'()' '<>' '[]'}'([<<)>>]'
 
@KamilaSzewczyk 1
 
@dzaima Yeah, I can see that 1 ¯1 0['()'⍳⍵] seems to have slowed down a lot from 18.0 to 18.2.
 
3:42 PM
last improvement, i promise. it could be made more general: '()' '<>' '[]' {∧/0(=∘⊃∘⌽∧∧/⍤≤)¨⍵∘{+\1 ¯1 0[⍺⍳⍨↑⍵]}¨⍺} '([<<)>>]'
 
(The name 18.2 is a bit misleading when it comes to performance. 18.2 is 17.1's engine with 18.0 features bolted on.)
 
@KamilaSzewczyk nice
 
@KamilaSzewczyk don't you want that to return 0?
 
why? stuff is matched.
 
"matched", but not syntactically correct in most programming languages.
 
3:43 PM
does the problem require preserving the closing order?
 
Yeah, it is an initial step of parsing.
)(2×3)+4( isn't considered balanced.
 
it doesn't sound like a hard fix.
 
Kind of like the mathematicians observing the shed, two people walking out, then two people walking in, one mathematician to the other: Now the shed is empty again!
 
      '()' '<>' '[]' {↑⍵∘{+\1 ¯1 0[⍺⍳⍨↑⍵]}¨⍺} '([<<)>>]'
1 1 1 1 0 0 0 0
0 0 1 2 2 1 0 0
0 1 1 1 1 1 1 0
 
3:46 PM
And with that, I'll take my leave. See you next week for 2013-5: Identity Crisis!
 
one could observe that the running sum decrements in the first row, but this also happens when other braces are open.
 
some homework for us @KamilaSzewczyk
 
i can't say that i particularly miss homework
but i will think about this problem because it sounds interesting lol
 
:)
 
@KamilaSzewczyk all you really need is ∧/'()' '<>' '[]'genericSingleBracketTypeSolution¨∘⊂ if you're fine with interleaving
 
3:56 PM
@KamilaSzewczyk Wait, what's the for? Why not just write ⍵⍳⍺?
 
redundant after i yeeted rank.
 
here's a proper matching bracket solution
 
'()' '<>' '[]' {+\1 ¯1 0[⍺∘.⍳⍵]} '([<<)>>]' seems to work too. No idea what to do after that though, guess I'll just read dzaima's solution lol
 
4:51 PM
What's a good (efficient) way to generate all permutations of a string up to a certain length, with replacement? So for 'ABC' and 3, I'd want 'A B C AA AB AC AAA AAB AAC ABA ACA ... etc.
 
@xpqz (,/⍳∘≢{,↓⍵[↑,¨⍳⍺⍴≢⍵]}¨⊂) 'ABC' is one way; actually needed a to avoid ⍳,N being broken :D
but there isn't gonna be much efficient if you want an array of ragged vectors
 
Maybe equal-length vectors of indexes where the 'missing' slots are filled with 1+≢ or ¯1 or something?
or the shorter ones padded with spaces to make up the length
might work
...tryingh
 
5:11 PM
wondering if {⍉0,(≢⍵)⊥⍣¯1⍳¯1+*⍨≢⍵} could be of any use.
it's kinda fun.
 
5:52 PM
@dzaima @KamilaSzewczyk this was for a rosalind problem (rosalind.info/problems/lexv). Here's what I ended up with, using @dzaima's idea:
data←'DBREQFKCMIAL'
len←3
s←↑len {⊃,/(⍳⍺){,↓⍵[↑,¨⍳⍺⍴≢⍵]}¨⊂⍵} data
out←s[(' ',data)⍋s;]
(⊂↓out)⎕NPUT'lexv-out.txt'1
Dyadic grade, nice.
 
 
1 hour later…
7:12 PM
What is the best way to convert a 2D array A with columns specified in 2D cartesian coordinates into the corresponding 2D array B with columns specified in complex coordinates, so that we obtain B[;i] ≡ A[;i]+0j1×A[;i+1] where i∊¯1↓2⌷⍴A?
Alternatively we can put it like this, say you have a 2D array A, let's call its columns x1 y1 x2 y2 ... xn yn. What is the best way to construct an array with columns (x1+0j1×y1) (x2+0j1×y2) ... (xn+0j1×yn)?
 
 
2 hours later…
8:53 PM
⋄ m,⍥⊆1 0J1 +.×⍤1⊢5 4 2 ⍴ m←5 8 ⍴ ⍳40
 
@rak1507
┌───────────────────────┬───────────────────────┐
│ 1  2  3  4  5  6  7  8│ 1J02  3J04  5J06  7J08│
│ 9 10 11 12 13 14 15 16│ 9J10 11J12 13J14 15J16│
│17 18 19 20 21 22 23 24│17J18 19J20 21J22 23J24│
│25 26 27 28 29 30 31 32│25J26 27J28 29J30 31J32│
│33 34 35 36 37 38 39 40│33J34 35J36 37J38 39J40│
└───────────────────────┴───────────────────────┘
 
like this? @11Kilobytes
 
Yes @rak1507! Beautiful!
How does that work idgi though?
 
@11Kilobytes so the full function would be {1 0J1+.×⍤1⊢⍵⍴⍨(≢⍵),2,⍨2÷⍨⊃⌽⍴⍵} which reshapes into 3d and then does a dot product with 1 0J1 for each of the two elements
⋄ 5 4 2 ⍴ m←5 8 ⍴ ⍳40
 
@rak1507
 1  2
 3  4
 5  6
 7  8

 9 10
11 12
13 14
15 16

17 18
19 20
21 22
23 24

25 26
27 28
29 30
31 32

33 34
35 36
37 38
39 40
 
9:03 PM
Thanks @rak1507, I was about to say that the main trick is introducing a new dimension by 8≡4×2. Cool stuff.
Meanwhile like a typical FP enthusiast but APL novice my best thought so far was: {⍉↑(⊣+0J1×⊢)/¨⍵⊂⍨2|⍳2⌷⍴⍵}
 
well, that's pretty nice imo
{1 0J1+.×,⍵}⌺(2 2⍴1 2) is short but slow
 
@Adám my cousin is live on Xfactor \ (•◡•) /
 
1 0J1+.×⍨⊢⍴⍨≢,2,⍨2÷⍨≢⍤⍉ is pretty fast and short
(faster than my first attempt, realised I could do +.×⍨ instead of +.×⍤1)
@BrianBED fascinating but I'm not sure why that's apl related :P
 

« first day (1857 days earlier)      last day (780 days later) »