f# - Pipeline List with Constant Parameters -
i'm trying create pipeline consists of main parameter being list constant.
as simple example
type clocktype = | in | out let clockmap index offset = match index | index when index + offset % 2 = 0 -> in | _ -> out let mapit offset = [0 .. 23] |> list.map offset it works when take out offset. i've tried doing tuple doesn't int list. best way go this?
i'm learning f# bear me.
is you're after?
type clocktype = in | out let clockmap offset index = if (index + offset) % 2 = 0 in else out let mapit offset = [0 .. 23] |> list.map (clockmap offset) output be:
mapit 3 |> printfn "%a" // [out; in; out; in; out; in; out; in; out; in; out; in; out; in; out; in; out; // in; out; in; out; in; out; in] if so, there multiple issues:
clockmap's parameters backwards%has higher precedence+clockmapnever being called (andoffsetneeds partially appliedclockmap)
the change match if purely readability, , idiomatically, non-literal let bound values start lowercase characters (type names , class properties/methods start uppercase).
Comments
Post a Comment