| M261 pseudo code | JavaScript |
| SECONDCHAR : S -> C
s |-> sigma |
function SECONDCHAR(s) {
//S -> C , a comment. |
| domain LEN(s) > 1 | if (LEN(s)< 2)
return false
//the domain condition |
| alg
sigma = FIRST(REST(s)) |
return FIRST(REST(s))
} |
| M261 Pseudo code | JavaScript |
| NAME : Set1 -> Set2
input |-> output |
function NAME(input){1 //2 Set1 -> Set2 |
| domain boolean [that defines the subset of Set1 of valid inputs.] | if (boolean) return
false
// domain condition catches invalid inputs 3 |
| alg
lines of code --- --- output = ... |
lines of
code, each line terminated by a <return> and/or a ';' return 4 ... }1 |
| It is not absolutely necessary to place the domain
condition in the JS function. You could just remember not to use an invalid
input. However, if you use the function in a composite call of functions,
then writing in the domain condition becomes an essential part of
the function algorithm.
Note that if D is the domain set then we can either use the boolean condition of Compliment(D), as on the right above, or use that of D in the form; -------{ if (boolean D) {..the function body..} else return false } |
Remarks
|