Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let findBest best lowest next =
- let bestProfitCandidate = next - lowest
- if bestProfitCandidate > best then bestProfitCandidate else best
- let maxProfit lst =
- let rec calcMaxProfit lowest best rem =
- match rem with
- | [] -> best
- | x::xs -> let lowest' = if x < lowest then x else lowest
- calcMaxProfit lowest' (findBest best lowest x) xs
- let startLow = List.nth lst 0
- calcMaxProfit startLow 0 lst
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement