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. |
|||
00:14
MasterDuke joined
|
|||
nhail | This is a bit of an XY problem, because it isn't really raku-specific, but I'm posting it here because I'm writing this in raku :p. I'm trying to make a program which plays music, and the method I've found for this is the MPV ipc interface here: mpv.io/manual/master/#json-ipc This works well enough, I can send commands with this code (replacing ... with some string manipulation): shell "echo ... | | 02:10 | |
socat - /tmp/mpvsocket" but I would like to make use of the event part of this protocol as well, and I'm not sure how to do that. I'm guessing it will be something with Proc, but I don't really know what. | |||
(deleted my message, gonna post it elsewhere because it's unrelated to raku actually) | 02:21 | ||
02:25
teatime left
02:26
teatime joined
02:47
teatwo joined
02:51
teatime left
05:10
MasterDuke left
08:07
dakkar joined
12:01
mjgardner left,
mjgardner joined
12:27
jgaz left
12:32
jgaz joined
|
|||
Anton Antonov | Now I am curious... | 12:33 | |
12:38
jgaz left,
jgaz joined
13:00
dakkar left,
dakkar joined
14:25
tea3po joined
14:28
teatwo left
|
|||
nhail | The original question was just me not understanding socat. Now, I don't understand socat and am having issues with Proc::Async. I'll figure it out though. | 15:53 | |
16:35
dakkar left
17:16
Anant joined
|
|||
Anant | Why does (^3).max give 3 | 17:18 | |
lizmat | that feels.. wrong :-) | 17:23 | |
Tirifto | The docs comment Range’s ‘max’ method with: ‘Returns the end point of the range.’ | 17:24 | |
And show the same result for both inclusive and non-inclusive… so unless the examples are auto-generated and this was not intended, I would assume that the end point is considered the same, regardless of whether it is inclusive or not. | |||
Not that I would anticipate it. :-) | 17:25 | ||
Anant | A bit counter-intuitive, since I expected (^3) to represent (0, 1, 2) | 17:27 | |
max(^3) gives 2 though | 17:29 | ||
nhail | I think (^3).max and max(^3) should be the same, whichever they are | 17:37 | |
lizmat | agree | 17:39 | |
other weird cases; | 17:40 | ||
m: say max (10..-10) | |||
camelia | -Inf | ||
lizmat | m: say (10..-10).max | 17:41 | |
camelia | -10 | ||
lizmat | the first because (10..-10).list is an empty list | 17:42 | |
m: say ().max | |||
camelia | -Inf | ||
lizmat | I guess that's the reason for the "end-point" semantics currently | 17:43 | |
ah.... max / min are the attributes on the Range object, duh | 17:45 | ||
17:57
tea3po left,
tea3po joined
|
|||
lizmat | Tirifto: github.com/rakudo/rakudo/pull/5300 | 18:18 | |
Anant ^^ | 18:20 | ||
nhail ^^ | |||
Tirifto | lizmat, elegant. :-) | ||
18:47
Anant left
|
|||
nemokosch | I thought "max" was more or less an accidental attribute of Ranges, there is something else for them as well iirc | 18:49 | |
librasteve | the relevant design doc for Range min max is here design.raku.org/S03.html#Range_and..._semantics (line 3527) | 22:14 | |
it begs the question what should this be | 22:15 | ||
m: (2.7..^9.3).max.say | |||
Raku eval | 9.3 | ||
librasteve | if not 9.3? | 22:16 | |
Range method minmax seems to have the situation right and could be generalised to the min and max operations | 22:18 | ||
If the Range is an integer range (as indicated by is-int), then this method returns a list with the first and last value it will iterate over (taking into account excludes-min and excludes-max). If the range is not an integer range, the method will return a two element list containing the start and end point of the range unless either of excludes-min or excludes-max are True in which case a Failure is | |||
returned. | |||
nhail | I am attempting to use mpv's JSON IPC via socat, but running into issues. This code is mainly adapted from the Proc::Async demo code in the documentation: our $mpvproc = run <mpv --idle --input-ipc-server=/tmp/mpvsocket>, :out; our $socatproc = Proc::Async.new: :w, <socat - /tmp/mpvsocket>; # Async user input handling react { whenever $socatproc.stdout.lines { # split input on \r\n, \n, and \r say | 22:25 | |
'line: ', $_ } whenever $socatproc.stderr { # chunks say 'stderr: ', $_ } whenever $socatproc.ready { say 'PID: ', $_ # Only in Rakudo 2018.04 and newer, otherwise Nil } whenever $socatproc.start { say 'Proc finished: exitcode=', .exitcode, ' signal=', .signal; } whenever $socatproc.print: '{"command":["get_property", "pause"]}' { say 'sent message' | |||
} } # Cleanup LEAVE { $socatproc.say: '{"command": ["quit"]}'; $socatproc.kill; } But this gives me the following output (line 49 is the react): PID: 22337 A react block: in block <unit> at ./async_testing.raku line 49 Died because of the exception: Cannot write to process that has already terminated in block <unit> at ./async_testing.raku line 49 I will also note the output from doing this "by | |||
hand" in my terminal (the 1st and 3rd lines of the socat "output" are actually typed by me): $ mpv --idle --input-ipc-server=/tmp/testingsocket & [1] 21548 $ socat - /tmp/testingsocket {"command":["get_property", "pause"]} {"data":false,"request_id":0,"error":"success"} {"command":["quit"]} {"data":null,"request_id":0,"error":"success"} Exiting... (Quit) [1] + 21548 done mpv --idle | |||
--input-ipc-server=/tmp/testingsocket |