How to resolve the algorithm Partial function application step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Partial function application step by step in the Raku programming language
Table of Contents
Problem Statement
Partial function application is the ability to take a function of many parameters and apply arguments to some of the parameters to create a new function that needs only the application of the remaining arguments to produce the equivalent of applying all arguments to the original function. E.g:
Note that in the partial application of a parameter, (in the above case param1), other parameters are not explicitly mentioned. This is a recurring feature of partial function application.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Partial function application step by step in the Raku programming language
Source code in the raku programming language
sub fs ( Code $f, @s ) { @s.map: { .$f } }
sub f1 ( $n ) { $n * 2 }
sub f2 ( $n ) { $n ** 2 }
my &fsf1 := &fs.assuming(&f1);
my &fsf2 := &fs.assuming(&f2);
for [1..3], [2, 4 ... 8] X &fsf1, &fsf2 -> ($s, $f) {
say $f.($s);
}
You may also check:How to resolve the algorithm Temperature conversion step by step in the C programming language
You may also check:How to resolve the algorithm Compare a list of strings step by step in the Bracmat programming language
You may also check:How to resolve the algorithm XML/Input step by step in the J programming language
You may also check:How to resolve the algorithm The Name Game step by step in the q programming language
You may also check:How to resolve the algorithm List comprehensions step by step in the Fortran programming language