« first day (884 days earlier)      last day (1771 days later) » 

6:50 AM
0
Q: Apl Nars: Rational representation and numerator

RosLuPIn Nars fractions are represented using 'r' example 23r45 will be the fraction 23/45. The problem if I have one variable that contain one rational number, how to accede to numerator? Exist one function 'numerator' such that numerator 23r45 return 23? Thank you and Good morning

 
 
2 hours later…
8:55 AM
@dzaima Hm, isn't a better symbol for juxtapose {⍺⍵} than ?
Although, it'd be hard to distinguish from ⊣⊢ in handwriting and proportional fonts.
 
@Adám also looks a bit like + or ÷ if it's that compressed, it being 2 tacks doesn't really make sense in any context of the current language, and is pretty good already imo
 
@dzaima Right. As opposed to ⍺⍵, ⊣⊢ can't ever juxtapose. It would just have looked cool in the last code block here.
 
 
4 hours later…
 
3 hours later…
3:43 PM
I have a list of data where each index is the same shape as the next
(3 3⍴⍳9) (3 3⍴ 'blah' 'bluh') (3 3⍴'a' 2 'whatever')
I need to now relate each cell of each matrix to the same cell in each other matrix
in this case
1 'blah' 'a'
2 'bluh' 2
3 'blah' 'whatever'
...
etc
{↑¨⊂⊂⍤¯1⍉↑⍵} data
From @Adám this gets me close, but the resulting matrix needs to be 2d in all cases
 
@Nathan wouldn't ↓⍉↑data suffice?
⎕←↓⍉↑(3 3⍴⍳9)(3 3⍴ 'blah' 'bluh')(3 3⍴'a' 2 'whatever')
 
@J.Sallé
┌─────────────────┬─────────────────┬─────────────────┐
│┌─┬────┬─┐       │┌─┬────┬─┐       │┌─┬────┬─┐       │
││1│blah│a│       ││4│bluh│a│       ││7│blah│a│       │
│└─┴────┴─┘       │└─┴────┴─┘       │└─┴────┴─┘       │
├─────────────────┼─────────────────┼─────────────────┤
│┌─┬────┬─┐       │┌─┬────┬─┐       │┌─┬────┬─┐       │
││2│bluh│2│       ││5│blah│2│       ││8│bluh│2│       │
│└─┴────┴─┘       │└─┴────┴─┘       │└─┴────┴─┘       │
├─────────────────┼─────────────────┼─────────────────┤
 
Maybe this one is better:
⎕←⍉↓⍉↑(3 3⍴⍳9)(3 3⍴ 'blah' 'bluh')(3 3⍴'a' 2 'whatever')
 
@J.Sallé
┌──────────┬──────────┬─────────────────┐
│┌─┬────┬─┐│┌─┬────┬─┐│┌─┬────┬────────┐│
││1│blah│a│││2│bluh│2│││3│blah│whatever││
│└─┴────┴─┘│└─┴────┴─┘│└─┴────┴────────┘│
├──────────┼──────────┼─────────────────┤
│┌─┬────┬─┐│┌─┬────┬─┐│┌─┬────┬────────┐│
││4│bluh│a│││5│blah│2│││6│bluh│whatever││
│└─┴────┴─┘│└─┴────┴─┘│└─┴────┴────────┘│
├──────────┼──────────┼─────────────────┤
│┌─┬────┬─┐│┌─┬────┬─┐│┌─┬────┬────────┐│
││7│blah│a│││8│bluh│2│││9│blah│whatever││
│└─┴────┴─┘│└─┴────┴─┘│└─┴────┴────────┘│
 
not quite
1 blah a
2 bluh 2
3 blah whatever
4 bluh a
5 blah 2
 
etc. it needs to be a 2d table
each cell is a "row" in the 2d table
 
⎕←⍪,⍉↓⍉↑(3 3⍴⍳9)(3 3⍴ 'blah' 'bluh')(3 3⍴'a' 2 'whatever')
 
@J.Sallé
┌─────────────────┐
│┌─┬────┬─┐       │
││1│blah│a│       │
│└─┴────┴─┘       │
├─────────────────┤
│┌─┬────┬─┐       │
││2│bluh│2│       │
│└─┴────┴─┘       │
├─────────────────┤
│┌─┬────┬────────┐│
││3│blah│whatever││
│└─┴────┴────────┘│
├─────────────────┤
│┌─┬────┬─┐       │
││4│bluh│a│       │
│└─┴────┴─┘       │
├─────────────────┤
│┌─┬────┬─┐       │
││5│blah│2│       │
│└─┴────┴─┘       │
├─────────────────┤
│┌─┬────┬────────┐│
││6│bluh│whatever││
│└─┴────┴────────┘│
├─────────────────┤
 
that's the part I'm having a problem with. keep everything in tact, just reduce by 1 dimension
 
@Nathan like so?
 
3:57 PM
⎕←↑,/⍪,⍉↓⍉↑(3 3⍴⍳9)(3 3⍴ 'blah' 'bluh')(3 3⍴'a' 2 'whatever')
 
@Nathan
┌─┬────┬────────┐
│1│blah│a       │
├─┼────┼────────┤
│2│bluh│2       │
├─┼────┼────────┤
│3│blah│whatever│
├─┼────┼────────┤
│4│bluh│a       │
├─┼────┼────────┤
│5│blah│2       │
├─┼────┼────────┤
│6│bluh│whatever│
├─┼────┼────────┤
│7│blah│a       │
├─┼────┼────────┤
│8│bluh│2       │
├─┼────┼────────┤
│9│blah│whatever│
└─┴────┴────────┘
 
@Nathan the reduction in ,/ is unnecessary:
⎕←↑,⍪,⍉↓⍉↑(3 3⍴⍳9)(3 3⍴ 'blah' 'bluh')(3 3⍴'a' 2 'whatever')
 
@J.Sallé
┌─┬────┬────────┐
│1│blah│a       │
├─┼────┼────────┤
│2│bluh│2       │
├─┼────┼────────┤
│3│blah│whatever│
├─┼────┼────────┤
│4│bluh│a       │
├─┼────┼────────┤
│5│blah│2       │
├─┼────┼────────┤
│6│bluh│whatever│
├─┼────┼────────┤
│7│blah│a       │
├─┼────┼────────┤
│8│bluh│2       │
├─┼────┼────────┤
│9│blah│whatever│
└─┴────┴────────┘
 
I'm sure @Adám can give you a cleaner solution, though
 
this doesn't account for a case where the shape isn't a matrix
 
3:59 PM
Yes, they'll all need to be same shape matrices for it to work, I think
 
hmm
no that isn't what I'm saying. of course they're the same shape, but if the shape of the "same shape" is 1
(3⍴⍳9)(3⍴ 'blah' 'bluh')(3⍴'a' 2 'whatever')
for instance
 
That works too, unless I'm misunderstanding what you want here
⎕←↑,/⍪,⍉↓⍉↑(3⍴⍳9)(3⍴ 'blah' 'bluh')(3⍴'a' 2 'whatever')
 
@J.Sallé
┌─┬────┬────────┐
│1│blah│a       │
├─┼────┼────────┤
│2│bluh│2       │
├─┼────┼────────┤
│3│blah│whatever│
└─┴────┴────────┘
 
⎕←data←((4 4⍴(⎕io-⍨⍳9),⎕io-⍨⍳7) (4 5 6)) ((4 4⍴⊂'A1') (3⍴⊂'d8')) ((4 4⍴'n') 'sss') ((4 4⍴0) '111') ⋄
⎕←⍪/{⍵⍴⍨¯2↑1,⍴⍵}¨⊂⍤¯1⍉↑⍵}⍤1⍉↑data
@DyalogAPL?
⎕←⍪/{⍵⍴⍨¯2↑1,⍴⍵}¨⊂⍤¯1⍉↑⍵}⍤1⍉↑⎕←((4 4⍴(⎕io-⍨⍳9),⎕io-⍨⍳7) (4 5 6)) ((4 4⍴⊂'A1') (3⍴⊂'d8')) ((4 4⍴'n') 'sss') ((4 4⍴0) '111')
 
@Adám
  0 1 2 3  4 5 6     A1  A1  A1  A1    d8  d8  d8     nnnn  sss    0 0 0 0  111
  4 5 6 7            A1  A1  A1  A1                   nnnn         0 0 0 0
  8 0 1 2            A1  A1  A1  A1                   nnnn         0 0 0 0
  3 4 5 6            A1  A1  A1  A1                   nnnn         0 0 0 0
 0  A1 n 0
 4  A1 n 0
 8  A1 n 0
 3  A1 n 0
 1  A1 n 0
 5  A1 n 0
 0  A1 n 0
 4  A1 n 0
 2  A1 n 0
 6  A1 n 0
 1  A1 n 0
 5  A1 n 0
 3  A1 n 0
 7  A1 n 0
 2  A1 n 0
 6  A1 n 0
 4  d8 s1
 5  d8 s1
 
4:03 PM
no wait yes it does
I was doing something funky with my data here locally
⎕←({{↑,/⍪,⍵}¨⊂↓⍉↑ ⍵}⍤1)⍉↑((4 4⍴(⎕io-⍨⍳9),⎕io-⍨⍳7) (4 5 6)) ((4 4⍴⊂'A1') (3⍴⊂'d8')) ((4 4⍴'n') 'sss') ((4 4⍴0) '111')
 
@Nathan
┌──────────┬──────────┐
│┌─┬──┬─┬─┐│┌─┬──┬─┬─┐│
││0│A1│n│0│││4│d8│s│1││
│├─┼──┼─┼─┤│├─┼──┼─┼─┤│
││4│A1│n│0│││5│d8│s│1││
│├─┼──┼─┼─┤│├─┼──┼─┼─┤│
││8│A1│n│0│││6│d8│s│1││
│├─┼──┼─┼─┤│└─┴──┴─┴─┘│
││3│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││1│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││5│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││0│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││4│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││2│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││6│A1│n│0││          │
 
that's what I needed
 
@Nathan ⍪, is
 
and I guess I still don't need /
⎕←({{↑,⍪⍵}¨⊂↓⍉↑ ⍵}⍤1)⍉↑((4 4⍴(⎕io-⍨⍳9),⎕io-⍨⍳7) (4 5 6)) ((4 4⍴⊂'A1') (3⍴⊂'d8')) ((4 4⍴'n') 'sss') ((4 4⍴0) '111')
 
@Nathan
┌──────────┬──────────┐
│┌─┬──┬─┬─┐│┌─┬──┬─┬─┐│
││0│A1│n│0│││4│d8│s│1││
│├─┼──┼─┼─┤│├─┼──┼─┼─┤│
││4│A1│n│0│││5│d8│s│1││
│├─┼──┼─┼─┤│├─┼──┼─┼─┤│
││8│A1│n│0│││6│d8│s│1││
│├─┼──┼─┼─┤│└─┴──┴─┴─┘│
││3│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││1│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││5│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││0│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││4│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││2│A1│n│0││          │
│├─┼──┼─┼─┤│          │
││6│A1│n│0││          │
 
4:28 PM
thanks @J.Sallé @Adám this really cleaned up my code significantly
 
As predicted, Adám had the better solution hahahahahah
@Adám I like that this is completely and utterly terrifying if you don't know any APL, and just a big ol' function when you do
 
@DyalogAPL wait what adams messages contained an unmatched }
 
4:58 PM
@dzaima yeah, the syntax error was thrown I think
But there's a ⎕← before the function is run, I think that's why it printed stuff
same happens in my repl
 
i really don't know how i feel about this just working
right just this does too
 
Weird
 
5:18 PM
@Nathan Any the reason the trivial ⍉↑,¨ does not do the job?
⎕←⍉↑,¨(3 3⍴⍳9) (3 3 ⍴'Blah' 'Bluh') (3 3 ⍴'a' 2 'Whatever')
 
@PaulMansour
┌─┬────┬────────┐
│1│Blah│a       │
├─┼────┼────────┤
│2│Bluh│2       │
├─┼────┼────────┤
│3│Blah│Whatever│
├─┼────┼────────┤
│4│Bluh│a       │
├─┼────┼────────┤
│5│Blah│2       │
├─┼────┼────────┤
│6│Bluh│Whatever│
├─┼────┼────────┤
│7│Blah│a       │
├─┼────┼────────┤
│8│Bluh│2       │
├─┼────┼────────┤
│9│Blah│Whatever│
└─┴────┴────────┘
 
5:33 PM
There is either a whole lot of unnecessary complication going on here, or I have no idea what the problem really is. Probably the latter.
 
6:25 PM
o7 @PaulMansour
I'm having some funny behavior
 
6:54 PM
disregard
 
 
2 hours later…
8:39 PM
why
(3 4)∊(1 2)(3 4)
0 0

instead of return 1?

o (1 2)(3 4)
┌2────────────┐
│┌2───┐ ┌2───┐│
││ 1 2│ │ 3 4││
│└~───┘ └~───┘2
└∊────────────┘

this is ok

the woraround seems this

(⊂3 4)∊(1 2)(3 4)
1
 
Seems weird to me as well, especially since 3 4≡2⊃(1 2)(3 4) returns 1
Ah, I see.
@RosLuP (3 4) is not the same as ⊂3 4 here.
⎕←(3 4) ⋄ ⎕←(⊂3 4)
 
@J.Sallé
3 4
┌───┐
│3 4│
└───┘
 
@RosLuP ^
 
@RosLuP that's just how works - it says which elements in the left argument array are in the right one. For example, 3 4∊1 2 3 gives 1 0 as it should
the common 3∊1 2 3 4 meaning "is 3 in 1 2 3 4" actually is supposed to be (⊂3) ∊ 1 2 3 4, but there's no difference from 3 and ⊂3 so it works without it
 

« first day (884 days earlier)      last day (1771 days later) »