How to resolve the algorithm Optional parameters step by step in the Racket programming language
How to resolve the algorithm Optional parameters step by step in the Racket 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 Racket programming language
Source code in the racket programming language
#lang racket
(define (sort-table table
[ordering string<=?]
[column 0]
[reverse? #f])
(sort table (if reverse?
(negate ordering)
ordering)
#:key (λ (row) (list-ref row column))))
You may also check:How to resolve the algorithm Goldbach's comet step by step in the Julia programming language
You may also check:How to resolve the algorithm Square form factorization step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Joystick position step by step in the Julia programming language
You may also check:How to resolve the algorithm Read a specific line from a file step by step in the VBScript programming language
You may also check:How to resolve the algorithm Sleeping Beauty problem step by step in the J programming language