Sha256: 9e0106ce2d4dcf53e9226dec2331a2b1ecd21b20e718dc8e58918c27652e82cc
Contents?: true
Size: 499 Bytes
Versions: 10
Compression:
Stored size: 499 Bytes
Contents
As F# is a functional language, we can easily create a list of pairs of the string name of a function and the function itself to iterate over printing the operation and applying the function to obtain the result: do let a, b = int Sys.argv.[1], int Sys.argv.[2] for str, f in ["+", ( + ); "-", ( - ); "*", ( * ); "/", ( / ); "%", ( % )] do printf "%d %s %d = %d\n" a str b (f a b) For example, the output with the arguments 4 and 3 is: 4 + 3 = 7 4 - 3 = 1 4 * 3 = 12 4 / 3 = 1 4 % 3 = 1
Version data entries
10 entries across 7 versions & 1 rubygems