This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
habere-et-disper Is it intended behaviour that I can write `my @foo = [1,2].push(3,4).skip` but not `my @foo = [1,2].skip.push(3,4)` ? 19:41
ab5tract it's intended inasmuch as .skip returns a Seq 19:46
m: dd [[1,2].skip].push(3,4); dd [1,2].skip.Array.push(3,4) 19:48
camelia [2, 3, 4]
[2, 3, 4]
ab5tract habere-et-disper: I wouldn't say it is intentional as much as it is a side effect of the decision to return a Seq from .skip 19:49
habere-et-disper Is there a way to work with a Seq instead and add items to it ? 19:50
And what is the way to `pop` multiple items from an array like `unshift` can add ? 19:51
ab5tract Regarding `pop`, I believe there were some discussions around that recently. I'll see if I can find what came of that 19:53
My opinion is that it's not necessary to add a .pop(Int $elems) candidate when .pop xx $elems exists
But that doesn't mean it wasn't added :) 19:54
You can definitely work with `Seq` and combine them, but they are immutable, so you can combine them into a new `Seq` but you can't append one to another 19:55
habere-et-disper How does `.pop xx $elems` work ? I'm trying to take the last two elements with: 19:57
m: say [1,2,3,4].pop xx 2
camelia (4 4)
ab5tract huh, that's unexpected :( 19:58
regarding playing with seqs: 19:59
m: my $s1 = [1,2,3].skip; my $s2 = [3,4,5,6].skip; dd (|$s1, |$s2).Seq
camelia (2, 3, 4, 5, 6).Seq
habere-et-disper Seems it's just doing:
m: say ( [1,2,3,4].pop ) xx 2
camelia (4 4)
ab5tract m: my @foo = [1,2,3]; dd @foo.pop xx 2 20:00
camelia (3, 2).Seq
ab5tract m: my @foo = [1,2,3]; say @foo.pop xx 2
camelia (3 2)
ab5tract Looks like it needs to be in a container
m: my ($a, $b) = [1,2].pop xx 2; dd :$a, :$b 20:01
camelia :a(2)
:b(2)
ab5tract yeah, it looks like it
habere-et-disper Okay -- container magic. Thanks @ab5tract 20:03
ab5tract It kind of makes sense that an in situ array is immutable in this regard 20:04
So I would say it is less container magic (which certainly is a thing sometimes) and more about the impossibility of keeping track of modifications to a structure that is not stored in a variable 20:06
habere-et-disper That's helpful thanks. I see `.shift xx $elems` works too so that approach is consistent unlike `push/pop($elems)`. 20:12
ab5tract habere-et-disper: here's the discussion around `pop($elems)` github.com/Raku/problem-solving/issues/436 20:22
habere-et-disper =b
ab5tract imo it is way more trouble than its worth, but please chime in there if you feel strongly about it
librasteve done 20:54
(not so strong though)
ab5tract habere-et-disper: a small example of playing around with Seqs gist.github.com/ab5tract/9979a3b22...950d76d0d1 20:57
habere-et-disper @ab5tract++ 20:59
librasteve_ www.irccloud.com/pastebin/UTXBcmJr 21:40
ab5tract librasteve_++ 21:44
librasteve there's probably a whole essay on why raku is built on Seqs ... i like that you can dive in to the iterator if you want, but that most of the effects don't need that 21:45
ab5tract I'll never understand why you switch back to Discord :P 21:46
For the purposes of demonstration, I thought it made sense to dive in a bit. 21:48
librasteve (i) other servers, (ii) it's where the cool folks are (sic), (iii) I can see history - really (iii) whenever I log off (MacOS) I have to restart IRCCloud and rejoin servers or look a tthe logs
ab5tract But indeed, many operations will preserve or produce Seqs
IRCCloud preserves history and servers for me but ymmv 21:49
librasteve yeah - I like that you can easily reach for the iterator if you need it 21:51
and I think that either your language is lazy (ie iterator oriented) or not from the get go - but you cant build it in later (I guess this was taken from Lisp) 21:52
ab5tract Hmm... I recall a lot iterator stuff being installed by lizmat fairly late in the game 21:53
But that might be orthogonal to your point, because obviously the framework for laziness was already there 21:54
librasteve although I endorse beginners to use Arrays and Hashes first since they are sweeter and more familiar to the (eg) Python JS folks
oh - well not all assumptions are good
;-) 21:55