s |
focus search bar ( enter to select, ▲ / ▼ to change selection) |
g e |
go to examples |
g m |
go to modules |
g o |
go to overview |
g r |
go to reference |
h |
toggle this help ( esc also exits) |
$
Indicates the authoritative variable type parameter for a polymorphic procedure. 1 2
// from: https://youtu.be/BwqeFrlSpuI?t=501
swap :: (a: ^$T, b: ^T) {
tmp := *a;
*a = *b;
*b = tmp;
}
// from: https://youtu.be/BwqeFrlSpuI?t=868
find :: (array: [] $T, item: T) -> s64 {
for array if it == item return it_index;
return -1; // (not found)
}
// from: https://youtu.be/BwqeFrlSpuI?t=1200
do_three_times :: (func: ($T) -> void, arg: T) {
for 1..3 func(arg);
}
what the dollar sign indicates is that this is a type variable which means we don’t know what type it is at declaration time. the type of this variable will be determined when the function is called.
“Polymorphic Procedures, part 1” YouTube, uploaded by Jonathan Blow, Apr 1, 2015, https://youtu.be/BwqeFrlSpuI?t=228 ⮌
the reason that we only use the dollar sign once is that the dollar sign tells us which argument is authoritative over what the type should be..
“Polymorphic Procedures, part 1” YouTube, uploaded by Jonathan Blow, Apr 1, 2015, https://youtu.be/BwqeFrlSpuI?t=360 ⮌
jailang
2019 pixeldroid
https://github.com/pixeldroid/jailang |
programming pages theme v0.5.21 (https://github.com/pixeldroid/programming-pages) |
s |
focus search bar ( enter to select, ▲ / ▼ to change selection) |
g e |
go to examples |
g m |
go to modules |
g o |
go to overview |
g r |
go to reference |
h |
toggle this help ( esc also exits) |