Quick actions

cmd+k|ctrl+k

Navigation

Languages

Max Adjacent Product

Snippet info

Language

Fsharp

Visibility

public

Author

mjg.py3

Created

2017-07-03T00:22:02Z

Updated

2017-07-03T00:22:13Z

let next memory current =
  let currentWinner = 
    match memory with
      | None, None ->              None
      | Some v, None ->            Some v
      | None, Some v ->            Some (v*current)
      | Some winning, Some last -> Some (max winning (current * last))

  currentWinner, Some current

let adjacentElementsProduct = fst << Array.fold next (None, None)
INFO