[00:04] *** deoac joined
[01:31] *** jgaz left
[02:19] *** deoac left
[04:48] *** CIAvash joined
[07:30] *** hythm joined
[07:59] *** dakkar joined
[08:09] *** hythm left
[10:07] *** CIAvash left
[10:07] *** CIAvash joined
[10:24] *** CIAvash left
[10:55] hey how do i take sclice of string in raku ?
[11:00] https://docs.raku.org/routine/substr#type/Strroutineroutine
[11:02] so substr($s,-8,-1) for last 8 chartetors ?
[11:10] substr(*-8)
[11:10] m: say "foobarbaz".substr(*-3)
[11:10] rakudo-moar 55952f679: OUTPUT: «baz»
[11:11] Dr.Doom ^^
[11:21] there is no "let's iterate this backwards" stuff
[11:22] I don't think there is anything like that in the whole language
[11:22] if you want the string backwards, you can use flip
[11:40] *** tea3po joined
[11:43] *** teatwo left
[11:55] *** tea3po left
[11:56] *** tea3po joined
[12:31] *** jgaz joined
[16:31] *** dakkar left
[16:47] equivalent to haskell 's iterate in raku
[16:51] you'll have to ask somebody who knows both languages 😄
[16:52] its a lazy list
[16:52] most operations create lazy data types by default
[16:52] what nemokosch said
[16:53] iterate(f, x) = x, f(x), f(f(x)), f(f(f(x))).....
[16:53] you could define something like this as x, &f ... *
[16:54] where x is the starting value and &f is a function that takes one argument
[16:54] I am not familiar with perl/raku can you please elaborate
[16:55] if you ask the questions you want to know the answer to 😛
[16:56] Dr.Doom are you aware of https://docs.raku.org/language/haskell-to-p6 ?
[16:56] for all practical purposes, this is a "sequence construct" that consists of some starting values, followed by a generator function, and then the ellipsis and the terminating condition
[16:57] but what if its not linear?
[16:58] nope it doesn't contain it
[16:58] what do you mean linear? &f is really just a function that takes an argument
[16:59] it could take more and then it would be a higher order recursion
[18:02] It would extend $x, f($x) ... * as a linear recursion But typing $x, &f ... * is not the same as that. Check out this page
[18:02] https://docs.raku.org/routine/%2E%2E%2E
[18:03] $x, f($x) ... * is not a linear recursion but quite possibly an arithmetic series
[18:04] you have two values and some attempt will be made to extrapolate a sequence from them
[18:18] exactly what i needed thanks @nhail
[18:19] yeah fixed, oops
[18:20] I think it always uses arithmetic.
[18:23] Sequence operator will do arithmetic and geometric series
[18:25] m: say 1,2,3 ... 8
[18:25] (1 2 3 4 5 6 7 8)
[18:25] m: say 1,2,4 ... 8
[18:25] (1 2 4 8)
[18:27] m: sub f($x) { $x ** 2 - 1 }; say 3, f(3) ... * < 1000;
[18:27] (3)
[18:28] tbh it's kinda strange but I made a thinko anyway
[18:28] m: sub f($x) { $x ** 2 - 1 }; say 3, f(3) ... * > 1000;
[18:28] (3 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 103 108 113 118 123 128 133 138 143 148 153 158 163 168 173 178 183 188 193 198 203 208 213 218 223 228 233 238 243 248 253 258 263 268 273 278 283 288 293 298 303 308 313 318 323 328 333 338 343 348 353 358 363 368 373 378 383 388 393 398 403 408 413 418 423 428 433 438 443 448 453 458 463 468 473 478 483 488 493 498 ...)
[18:28] this is an arithmetic series, the way it is
[18:28] we start with 3 and f(3) which is equal to 8
[18:29] m: sub f($x) { $x ** 2 - 1 }; say 3, &f ... * > 1000;
[18:29] (3 8 63 3968)
[18:29] this is an actual recursion
[18:29] I'm not strong with math lingo but I don't think this is linear in any sense
[19:48] m: say 1,2,5 ... 8
[19:48] Exit code: 1 Unable to deduce arithmetic or geometric sequence from: 1,2,5 Did you really mean '..'? in block at main.raku line 1
[20:02] *** jgaz left
[20:10] <.ohnowendigo> Does anyone have good examples of "small grammars"? Like only a handful of rules, solves a small problem they had
[20:15] #viz.https://docs.rs/polars/latest/polars/chunked_array/object/datatypes/index.html#types my @types = ; my @dtypes = ; my %type-map = @types Z=> @dtypes; use Grammar::Tracer; my grammar Lambda { rule TOP {
[20:15] } rule signature { '|' [',' ]? '|' } rule a-sig { 'a:' } rule b-sig { 'b:' } rule as-type { 'as' } rule body { '(' ')' > } rule expr { .* } token a-type { @types } token b-type { @types }
[20:15] token r-type { @types } } my $match = Lambda.parse($lambda); die "cannot match this lambda" unless $match.so;
[20:16] ^^ does this help? ... the taregt is eg. "|a: str, b: i32| (a.len() + b) as i32"
[20:18] or, this https://docs.raku.org/syntax/Creating%20grammars is pretty neat
[20:19] Grammar::Tracer is your best friend
[20:52] <.ohnowendigo> Omg that Z=> trick
[20:56] oh yeah, too much information
[20:59] then you can work out how to dereference the result via dd $match
[21:08] Z=> is kind of an established pattern at this point
[23:40] *** tea3po left
[23:40] *** tea3po joined