xxxxxxxxxx
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("square", type=int,
help="display a square of a given number")
parser.add_argument("-v", "--verbose", action="store_true",
help="increase output verbosity")
args = parser.parse_args()
answer = args.square**2
if args.verbose:
print("the square of {} equals {}".format(args.square, answer))
else:
print(answer)
xxxxxxxxxx
function addTogether() {
const [first, second] = arguments;
if (typeof(first) !== "number")
return undefined;
if (arguments.length === 1)
return (second) => addTogether(first, second);
if (typeof(second) !== "number")
return undefined;
return first + second;
}
xxxxxxxxxx
function addTogether(args) {
const [first, second] = args;
if (args.length === 1 && typeof first === 'number') {
return num => {
if (typeof num === 'number') {
return first + num;
}
}
}
if (typeof first === 'number' && typeof second === 'number') {
return first + second;
}
}