00:28
Oshawott joined
00:31
arch left
02:00
Kaiepi left
02:23
frost joined
03:27
Guest35_ left
08:05
jaguart joined
08:33
Kaiepi joined
08:38
jaguart left
10:20
kueppo joined
|
|||
kueppo | Morning, I've a problem with the '^' twigil, idk how the order btw these positional parameters works and how to name them | 10:24 | |
Like this example from the rakudoc | |||
my @powers-of-three = 1,3,9…100; | |||
say reduce { $^b - $^a }, 0, |@powers-of-three; | |||
after reading through it I still don't understand | 10:25 | ||
thanks in advance | 10:26 | ||
lizmat | m: say (* / *)(4,2) # kueppo: do you understand that? | 10:29 | |
camelia | 2 | ||
lizmat | m: say (* / *)(6,2) # perhaps better | 10:30 | |
camelia | 3 | ||
lizmat | m: say (-> $a, $b { $a / $b })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^a / $^b })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^b / $^a })(6,2) | 10:31 | |
camelia | 0.333333 | ||
10:31
kueppo left
10:43
razetime joined
|
|||
Nemokosch | Are the variable names magic names, then? | 10:52 | |
lizmat | nope | 10:59 | |
m: say (-> $foo, $bar{ $foo / $bar })(6,2) | 11:00 | ||
camelia | ===SORRY!=== Shape declaration is not yet implemented; please use whitespace if you meant something else at <tmp>:1 ------> say (-> $foo, $bar⏏{ $foo / $bar })(6,2) Variable '$bar' is not declared. Perhaps you forgot a 'sub' if… |
||
lizmat | m: say (-> $foo, $bar { $foo / $bar })(6,2) | ||
camelia | 3 | ||
lizmat | m: say ({ $^bar / $^foo })(6,2) | ||
camelia | 3 | ||
lizmat | because "bar" is alphabetically before "foo" | 11:01 | |
m: say ({ $^foo / $^bar })(6,2) | |||
camelia | 0.333333 | ||
lizmat | m: say (-> $bar, $foo { $foo / $bar })(6,2) | ||
camelia | 0.333333 | ||
Nemokosch | This is a point block though | 11:16 | |
lizmat | point blocks are just syntactic sugar to create a block | 11:18 | |
they're all Callables | |||
it's just that WhateverCodes such as |* + 3" are a bit simpler blocks, because they can never have phasers | 11:19 | ||
* + 3 | |||
:-) | |||
there is internally no difference between the Callable part of a sub / method / pointy block / block of an if / elsif / for / loop etc. | 11:20 | ||
it's just that subs have a name, and that blocks can have phasers | 11:21 | ||
Nemokosch | That's besides the point (pun not intended) | 12:01 | |
lizmat | ok, then what is the point ? | 12:02 | |
Nemokosch | How does the compiler know which value is $^a and which is $^b | ||
lizmat | variables of the form $^foo *generate* the signature of the block in which they occur | 12:03 | |
m: -> $foo { $^bar } | |||
camelia | ===SORRY!=== Error while compiling <tmp> Placeholder variable '$^bar' cannot override existing signature at <tmp>:1 ------> <BOL>⏏-> $foo { $^bar } |
||
lizmat | m: dd ({ $^bar }).signature | ||
camelia | :($bar) | ||
lizmat | m: dd ({ $^foo + $^bar }).signature | 12:04 | |
camelia | :($bar, $foo) | ||
lizmat | the compiler alphabetically sorts the names to create the signature | ||
Nemokosch | > alphabetically sorts the names | 12:16 | |
👏 |