|
00:34
Guest4 joined
|
|||
| Guest4 | The documentation for 'reduce' seems to imply it will simply return the sole item of a list when given a list of length 1, but I always seem to get a "too few positionals passed" error when I try. It seems to work with some built-ins, like &infix:<+>, but not with anything else I try. Is the documentation wrong? | 00:47 | |
| [Coke] | can you give an example that fails? | 01:24 | |
| m: say reduce &infix:<->, (1,); | |||
| camelia | 1 | ||
| [Coke] | if your sub only takes 2 args, it can't take just 1, so this will fail: | 01:25 | |
| m: sub j($a, $b) { $a * $b }; say reduce &j, (1,); | |||
| camelia | Too few positionals passed; expected 2 arguments but got 1 in sub j at <tmp> line 1 in block <unit> at <tmp> line 1 |
||
| [Coke] | m: sub j($a, $b=1) { $a * $b }; say reduce &j, (1,); | 01:26 | |
| camelia | 1 | ||
| [Coke] | but since the second arg has a default there, that will work. | ||
| Guest4: hope that helps. | |||
| Guest4 | Perhaps I am reading too much into the documentation. I was hoping I could avoid a bunch of length checks in my code and reduce would do it for me. | 01:31 | |
| [Coke] | are you trying to reduce with a builtin or your own 2-arg sub? | 01:32 | |
| Guest4 | My own. Not dissimilar to your second example. | 01:34 | |
| [Coke] | ok. the core ones do this not by having a single sub doing 1 and 2 arg versions, but with a multi sub. | 01:35 | |
| e.g. there is a multi sub infix:<+>($x) { $x.Numeric } | 01:36 | ||
| That's probably the easiest way to do it. Can you point me at the doc URL you were reading? I can add a note to that effect. | |||
| Guest4 | docs.raku.org/routine/reduce | 01:37 | |
| It never occurred to me to try a mutli sub. Thanks for the help. | 01:45 | ||
| [Coke] | I think the text there is incorrect, actually, it says: | 01:49 | |
| If list contains just a single element, the operator is applied to that single element if possible; if not, it returns the element itself. | |||
| I'll rework that sentence to mention the multi (and double check the reduce implemenation that this isn't an error) | 01:50 | ||
| Guest4: github.com/Raku/doc/issues/4816 | 01:51 | ||
|
02:01
hulk joined
02:02
kylese left
02:15
hulk left,
kylese joined
02:28
guifa_ left
02:29
guifa joined
02:33
rmv left
02:51
Guest4 left
03:03
leppard left
03:46
rmv joined
03:51
rmv left
04:39
hurufu joined
06:19
vrurg joined
06:22
vrurg_ left
06:33
rmv joined
06:38
rmv left
07:32
guifa left,
guifa_ joined
07:39
leppard joined
08:34
tonyo left
08:35
rmv joined
08:36
tonyo joined
08:39
rmv left
08:49
tonyo left
08:53
tonyo joined
09:01
tonyo left
09:03
tonyo joined
09:16
tonyo left
09:28
tonyo joined
09:33
tonyo left
09:34
tonyo joined
|
|||
| Voldenet | I say docs about sleep and one thing is peculiar to me - there exists Duration (that sleep accepts) but Duration can't be initialized with minutes, hours etc. | 09:46 | |
|
09:51
tonyo left
|
|||
| Voldenet | it can be done easily so maybe it could be accepted form of .new | 09:51 | |
| m: sub duration { my $n = DateTime.new(0); $n.later(|%_) - $n.$_ }; say duration(:2days); say duration :3hours; | 09:52 | ||
| camelia | 172800 10800 |
||
|
09:57
tonyo joined
|
|||
| lizmat | interesting idea | 09:59 | |
| I guess it makes sense up to :weeks | 10:00 | ||
|
10:04
oodani left
|
|||
| Voldenet | Duration having units overall makes sense, just maybe not when combined with sleep | 10:05 | |
|
10:05
oodani joined
|
|||
| lizmat | m: sleep Duration.new(1); say now - INIT now | 10:06 | |
| camelia | 1.001584075 | ||
| lizmat | think it works fine? | ||
| Voldenet | yeah, sleep accepts the duration | 10:07 | |
| duration gets converted into numeric probably | 10:08 | ||
| either way, C# has similar class (it uses ticks internally) and it accepts `(d?, h,m,s)` as .new (and has ToString for that): github.com/microsoft/referencesour...imespan.cs | 10:10 | ||
| lizmat | actually, Duration nowadays store nanoseconds | ||
| *stores | |||
|
10:14
tonyo left
|
|||
| Voldenet | tick in TimeSpan context is 100ns I think, so storing ns is more precise | 10:16 | |
| + can use nanosleep directly | |||
|
10:22
tonyo joined
10:23
rmv joined
10:24
rmv left,
rmv joined
|
|||
| rmv | Hi everyone, trying to upload my first zef package. Is the server down? fez upload failing with a bunch of timeouts... | 10:25 | |
|
10:27
tonyo left
|
|||
| lizmat | confirmed :-( | 10:29 | |
| .tell tonyo looks like fez is having issues | |||
| tellable6 | lizmat, I'll pass your message to tonyo | ||
| lizmat | rmv: only thing I can say is: please try again later | 10:30 | |
| and thank you for creating your first zef package! :-) | |||
| rmv | no worries, I'll try later! thanks | ||
| Voldenet | m: use MONKEY-TYPING; augment class Duration { multi method new { my $n = DateTime.new(0); $n.later(|%_) - $n.$_ }; method X { self.polymod(60,60,24).&{my@p=$_; (@p.first(*!=0,:end,:k) // 0…0).map({ @p[$_].fmt("%02d")}).join(":") } } }; for (:2days, :3hours, :4minutes, :5seconds, 6) { Duration.new(|$_).X.say } | 10:33 | |
| camelia | 02:00:00:00 03:00:00 04:00 05 06 |
||
| Voldenet | something like that is what I'd have in mind for additional .new and .Str, but if anyone is using Str then obviously it might stop working | ||
|
10:35
tonyo joined
10:40
tonyo left
10:44
belluzj joined
10:46
tonyo joined
10:47
belluzj left
11:10
Sgeo left
11:13
tonyo left
11:16
tonyo joined
|
|||
| lizmat | Voldenet: the logic in DateTime.later should probably be abstracted into Internals and then used for Duration as well | 11:19 | |
| or make Duration.new canonical and use that in DateTime.later | 11:22 | ||
|
11:30
tonyo left
11:35
tonyo joined
11:42
tonyo left
11:50
tonyo joined
12:15
tonyo left
12:19
tonyo joined
12:23
tonyo left
12:33
tonyo joined
12:38
tonyo left
12:48
tonyo joined
12:53
tonyo left
12:56
tonyo joined
|
|||
| Voldenet | I'm actually not sure, .later uses DateTime.move-by-unit or Date.move-by-unit which actually do operations on the storage | 13:08 | |
|
13:08
tonyo left
|
|||
| Voldenet | but in Duration case constants would be used to add to some base number | 13:09 | |
| so Duration could implement it in more trivial way | |||
|
13:19
tonyo joined
13:25
tonyo left
13:29
tonyo joined
13:34
tonyo left
13:41
tonyo joined
13:51
tonyo left
14:00
tonyo joined
14:05
tonyo left
14:08
Pixi` joined,
rnddim joined
14:09
Pixi left,
ShimmerFairy left
14:33
tonyo joined
14:44
tonyo left
14:54
tonyo joined
14:56
rmv left,
rmv joined
15:08
tonyo left
15:14
tonyo joined
15:20
tonyo left
15:25
tonyo joined
15:31
tonyo left
15:33
tonyo joined
15:38
tonyo left
15:47
tonyo joined
15:59
tonyo left
16:00
tonyo joined
16:09
tonyo left
16:17
tonyo joined
16:25
tonyo left
16:27
tonyo joined
16:37
tonyo left
16:47
tonyo joined
16:55
rmv left,
rmv joined
16:56
rmv left
16:57
rmv joined
17:05
tonyo left
17:17
guifa_ left,
guifa joined
17:19
tonyo joined
17:24
camelia left,
nine_ left
17:26
tonyo left,
camelia joined
17:29
nine joined,
tonyo joined
17:43
tonyo left
17:46
tonyo joined
17:51
tonyo left
|
|||
| apogee_ntv | Is fez working for everyone else? I'm just getting a hang when trying to run it with no output | 17:56 | |
| to upload or login | |||
| rmv | apogee_ntv: Had the same problem earlier. Seems to be down. | 18:02 | |
| apogee_ntv | F | 18:03 | |
| Who do we ping to fix it? :D | 18:04 | ||
|
18:07
tonyo joined
|
|||
| rmv | lizmat pinged tonyo (irclogs.raku.org/raku/2026-06-20.html#10:29) | 18:10 | |
|
18:11
tonyo left
18:13
tonyo joined
18:24
tonyo left
18:27
rmv left
18:30
tonyo joined
18:39
rmv joined
18:43
rmv left
18:47
tonyo left
18:55
tonyo joined
18:56
rnddim is now known as ShimmerFairy
18:59
tonyo left
19:03
Sgeo joined
19:07
rmv joined
19:24
tonyo joined
19:29
belluzj joined
19:32
tonyo left
19:38
wayland76 joined
19:39
wayland left
19:45
tonyo joined
19:52
tonyo left
19:57
rmv left
19:58
tonyo joined
20:00
rmv joined
20:03
silug left
20:08
tonyo left
20:09
tonyo joined
20:11
silug joined
20:13
hurufu left
20:15
tonyo left
20:20
tonyo joined
20:24
tonyo left
20:39
tonyo joined
20:43
librasteve_ left
20:45
tonyo left
20:50
tonyo joined
20:51
belluzj left
|
|||
| apogee_ntv | tonyo: Looks like fez upload is broken atm, has been for a few hours. | 21:01 | |
| (rmv said you're the person to ping :D) | |||
|
21:10
tonyo left
21:45
tonyo joined
21:50
tonyo left
22:12
tonyo joined
22:20
tonyo left,
tonyo joined
22:25
tonyo left
22:26
tonyo joined
22:31
tonyo left
22:37
tonyo joined
22:42
tonyo left
22:43
wayland76 left
23:01
tonyo joined
23:14
tonyo left
23:27
leppard|2 joined,
tonyo joined
23:29
leppard left
23:31
tonyo left
23:45
tonyo joined
23:50
tonyo left
23:56
tonyo joined
|
|||