| stevied | alright, thanks to everyone who has helped me. I was able to convert my module over to OO. It works, though I'm sure there's lots of room for improvement. Sorry it won't be useful to probably anyone: github.com/sdondley/Karabiner-CompModGenerator | 00:13 | |
|
04:50
CIAvash joined
|
|||
| gfldex | @stevied#8273 You can do even more OO in Template.rakumod by replacing line 20-26 with `render-list(|@values).join.trim-trailing` | 10:44 | |
|
10:59
Guest35 joined
11:00
Guest35 left
|
|||
| m:``` | 11:04 | ||
| my @params = <a b c>.map: { Parameter.new(:name('$' ~ $_)) }; | |||
| my $sig = Signature.new(:@params); | |||
| say $sig; | |||
| ``` | |||
| m:``` | 11:05 | ||
| my @params = <a b c>.map: { Parameter.new(:name('$' ~ $_)) }; | |||
| my $sig = Signature.new(:@params, :returns(Str)); | |||
| say $sig; | |||
| ``` | |||
| stevied | ok, cool. I'll check it out | 11:06 | |
| gfldex | @stevied#8273 Please note that Rakudo doesn't like to precompile MONKEYs. | ||
| stevied | funny, I just posted a question to rakuland on reddit about this | ||
| rakulang | 11:07 | ||
| www.reddit.com/r/rakulang/comments...egantraku/ | |||
| ah, yes. a signature object. that is so obvious I missed it š | 11:08 | ||
| gfldex | I'm checking right now if that is an ENODOC. | 11:09 | |
| Signature.new and Parameter.new are not in roast. So this might be an ENOSPEC. | 11:11 | ||
| stevied | not familiar with those terms | ||
| gfldex | ENODOC means: No where to be found on docs.raku.org/ | 11:13 | |
| ENOSPEC means: No where to be found in github.com/raku/roast | |||
| Any advanced Raku-beginner (you can read most Raku code) is well advised to read roast. This can lead to many ohh-that-works-too-?-moments. | 11:15 | ||
| stevied | yeah, so using .join doesn't work. The render-list function returns a sequence | 11:17 | |
| ok, thanks. I'll poke through that and see what I can figure out | 11:18 | ||
| actually, I think the larger problem is Template::Classic uses `gather` so I have to make separate class to $out to get everything out. There's probably a better way, but using a block method was all I could figure out | 11:20 | ||
| actually, I think the larger problem is Template::Classic uses `gather` so I have to make separate calss to $out to get everything out. There's probably a better way, but using a block method was all I could figure out | |||
| gfldex | m:``` | 11:28 | |
| class C { | |||
| has $.foo; | |||
| has $.bar; | |||
| method desc_gen { | |||
| say self.^attributesĀ».nameĀ».substr(2).map: { $_ => self."$_"() }; | |||
| } | |||
| } | |||
| C.new(:foo(42)).desc_gen; | |||
| ``` | |||
| That should eliminate the 2nd EVAL. | |||
| `.join` should work on a `Seq`. Sometimes you have to sneak a `.cache` in, tho. | 11:29 | ||
| stevied | @gfldex#8222 that signature object worked perfectly. nice. | 11:30 | |
| just had to change :returns(Str) to :returns(Seq). | 11:32 | ||
| that code above is pretty tricky. man | 11:36 | ||
| seems to work, though. awesome | 11:42 | ||
| i'll have to study that | |||
| @gfldex#8222 OK! I still got an amateurish loop to extract out the attributes names and value but got rid of the eval. Thanks! | 11:57 | ||
| ``` | |||
| my @test_values = self.^attributesĀ».nameĀ».substr(2).map: { $_, self."$_"() }; | |||
| for @test_values -> $pair { | |||
| push @usage_names, $pair[0]; | |||
| push @values, $pair[1]; | |||
| } | |||
| ``` | |||
| Tried using .join.cache and .cache.join methods. no luck. I keep getting ... for the output. maybe I'm using .cache wrong? | 12:09 | ||
| gfldex | If you get `...` you are calling `.gist` indirectly. | 12:14 | |
| stevied | here's the Template::Classic module: modules.raku.org/dist/Template::Cl...lassic.pm6 | 12:18 | |
| it does a lazy gather. I still haven't figure out how that works, exactly. | 12:19 | ||
| gfldex | m: dd (1..10).grep(* %% 2).map(* * 10).head(2); | 14:30 | |
| m:``` | 14:31 | ||
| class Generator does Iterable { | |||
| has $.code; | |||
| has $.input; | |||
| method iterator { | |||
| class :: does Iterator { | |||
| has $.code; | |||
| has $.input; | |||
| method pull-one { | |||
| loop { | |||
| my \value = $.input.pull-one; | |||
| next if value =:= Empty; | |||
| @stevied#8273 the two examples show what is going on under the hood. There is more to laziness, this is quite simplified. | 14:32 | ||
| tailgate | if I have a string i know is even length, how do I break it up into a list of 2 character substrings? e.g "ABCDEF" -> ("AB" "CD" "EF") | 16:11 | |
| lizmat | "ABCDEF".comb(2) | 16:13 | |
| tailgate | thanks! | 16:17 | |
| stevied | ok, thanks! I'l be looking at all your suggestions and code for my homework today | 17:20 | |
|
19:15
discord-raku-bot left,
discord-raku-bot joined
19:20
discord-raku-bot left,
discord-raku-bot joined
19:52
discord-raku-bot left,
discord-raku-bot joined
19:56
discord-raku-bot left
19:57
discord-raku-bot joined
20:18
discord-raku-bot left,
discord-raku-bot joined
20:22
gfldex left,
gfldex joined
20:23
discord-raku-bot left,
discord-raku-bot joined
21:19
discord-raku-bot left,
discord-raku-bot joined
21:22
gfldex left,
gfldex joined
22:13
discord-raku-bot left,
discord-raku-bot joined
22:17
discord-raku-bot left
22:18
discord-raku-bot joined
23:52
Manifest0 left
|
|||