if statement - F#: if-else as an expression (returning values)? -
Suppose i am trying to write a clone of xxd
command in f code in it There are two operation modes; To convert a binary file to hex dump, and another (selected by -r
) to convert the hex dump to a binary file.
Some languages allow me to write something like this:
let's (input file, hr passage) = if args [0] == "-R" then (args. [1], true) and (args. [0], false) ... if wrong == then proceed to the headline input file and reverse mode input file
but it does not seem compiled under F #, are there any idiomatic ways to write in F #? I'm not a big fan of riff
or unstable
, though I know that I will be able to write something like this with him:
Let's reverse = ref false false filename = RF args. [0] If! Args. [0] == "-R" is then Arvar: = true filename: = Args. [1] ... if false ==! Then the mood ahead! Input file and reverse modes! Input File
Note: I am not interested in good command line parser libraries, that I newsletter
.
it should be fine F #
let's (inputfile, harvre ) = If args. [0] = "-r" then (args. [1], true) Other (args. [0], false) ... If false = increase the forward input file and reverse mode input file
two changes: if
indent and ==
to =
Comments
Post a Comment