On Thu, Nov 25, 2021 at 04:27:42PM +0100, Laszlo Ersek wrote:
It provides the following examples, and states that they are
equivalent:
let sum = fun i j -> i + j;;
let sum = (fun i -> (fun j -> i + j));;
let sum i j = i + j;;
Why is the usage of "fun" awkward here?
They are equivalent, but no one is using the "fun" form in real code
because it's longer and more obscure for no reason.
Is the problem more that I used an explicit "offset"
parameter, so
sec0at is not defined as a partial function application?
I made two changes but didn't explain that well. Firstly get rid of
the "fun" as above:
let sec0at offset = Bytes.get_uint8 sec0 offset in
Secondly, you can drop the argument to produce this equivalent and
shorter form:
let sec0at = Bytes.get_uint8 sec0 in
(
https://rosettacode.org/wiki/Partial_function_application#OCaml)
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/