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 +
  • clockmap never being called (and offset needs partially applied clockmap)

the change match if purely readability, , idiomatically, non-literal let bound values start lowercase characters (type names , class properties/methods start uppercase).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -