normanrockwellesque | not sure how cool it is, but gather/take seems pretty nice: | 02:40 | |
``` | |||
my $num = 5; | |||
my @arr = gather { take $_ ** $_ for 1..$num } | |||
``` | |||
I tried getting something working with the sequence `...` operator but was unsuccessful... 😓 | 02:41 | ||
Nemokosch | something like | 10:43 | |
```perl | |||
my $num = 5; | |||
my @arr = 1..$num.map(*^2); | |||
``` | |||
maybe? | |||
something like | |||
```perl | |||
my $num = 5; | |||
my @arr = 1..$num.map(* **2); | |||
``` | |||
maybe? | |||
lizmat | my @arr = (1..$num).map(* ** 2) # precedence | 10:56 | |
lakmatiol | that takes the second power, it would be `(1..$num).map: {$_ ** $_}` as far as I can tell | 10:58 | |
Nahita | "list comprehension" is yet another way: `[$_ ** $_ for 1..$n]` | 11:44 | |
or with states: `1, {state $x = 1; ++$x ** $x } ... *` | 11:45 | ||
or more unreadable & assuming 0^0 = 0 because why not: `0, -> *@_ { +@_ ** +@_ } ... *` | 11:46 | ||
or more unreadable & assuming `0**0 = 0` because why not: `0, -> *@_ { @_ ** @_ } ... *` | |||
Nemokosch | oh right, didn't pay attention | 11:47 | |
but the general idea would be the same, with {$_ ** $_}, I guess | 11:48 | ||
but the general idea would be the same, with {$\_ ** $\_}, I guess | |||
lakmatiol | this is really easy in apl, but we don't get a join operator | 12:39 | |
``` | |||
*⍨⍳10 | |||
1 4 27 256 3125 46656 823543 16777216 387420489 1E10 | |||
``` | |||
this is really easy in apl, but we don't get a join metaoperator | |||
``` | |||
*⍨⍳10 | |||
1 4 27 256 3125 46656 823543 16777216 387420489 1E10 | |||
``` | |||
Nemokosch | don't forget that APL is for array manipulation and pretty much only that | 12:43 | |
lakmatiol | yeah, a join metaop would still be nice | ||
yeah, a join metaop would still be nice though | |||
Nemokosch | What would it do? | 13:14 | |
13:15
mfiano left
|
|||
unixcat64 | can't install Inline::Perl5 module with zef on Windows | 14:43 | |
Nahita | same here! | 15:34 | |
same here | 15:35 | ||
i was going to try NumPy etc. | |||
unixcat64 | I get `Failed to find dependencies: perl:from<native>` | ||
Nahita | oh I thought Inline::Python, sorry :p | 15:36 | |
I couldn't install that one; but let me also try Perl5 now | |||
oh I mistakenly read Inline::Python, sorry :p | |||
Same error! | 15:37 | ||
unixcat64 | @Nahita#3882 Try it with `zef install Inline::Perl5 --exclude="perl" --force-build` | 15:44 | |
I still get errors tho | 15:46 | ||
Nahita | yeah a lot of tests failed and it aborted at the end... | 15:47 | |
hyperreal | I submitted an issue on Inline::Perl5's github repo | 15:52 | |
gfldex | m: say (1..5)».&{ $^a ** $^a }; | 17:44 | |
`».` <-- most favourite Raku feature of mine | 17:45 | ||
hyperreal | what does `>>.` do? | 19:14 | |
gfldex | It calls the following method or callable on each element of a list. | 19:16 | |
Nemokosch | it's sort of a "feature abuse" though 😄 | 19:19 | |
after all, the hyper operators can do much more than that | 19:23 | ||
you could pass in a list of functions | |||
hyperreal | nice 🙂 | 19:24 | |
21:23
Petr joined
21:28
Petr left
|