How to resolve the algorithm Optional parameters step by step in the PARI/GP programming language
How to resolve the algorithm Optional parameters step by step in the PARI/GP programming language
Table of Contents
Problem Statement
Define a function/method/subroutine which sorts a sequence ("table") of sequences ("rows") of strings ("cells"), by one of the strings. Besides the input to be sorted, it shall have the following optional parameters: This task should be considered to include both positional and named optional parameters, as well as overloading on argument count as in Java or selector name as in Smalltalk, or, in the extreme, using different function names. Provide these variations of sorting in whatever way is most natural to your language. If the language supports both methods naturally, you are encouraged to describe both. Do not implement a sorting algorithm; this task is about the interface. If you can't use a built-in sort routine, just omit the implementation (with a comment). See also:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Optional parameters step by step in the PARI/GP programming language
Source code in the pari/gp programming language
sort(v, ordering=0, column=0, reverse=0)
/*
GP;install("test_func", "vDG", "test", "path/to/test.gp.so");
*/
void
test_func(GEN x) {
if (x == NULL)
pari_printf("Argument omitted.\n");
else
pari_printf("Argument was: %Ps\n", x);
}
You may also check:How to resolve the algorithm Integer sequence step by step in the Ruby programming language
You may also check:How to resolve the algorithm Kaprekar numbers step by step in the REXX programming language
You may also check:How to resolve the algorithm Execute Brain step by step in the Ruby programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the Factor programming language
You may also check:How to resolve the algorithm Semordnilap step by step in the Quackery programming language