Guest User

Untitled

a guest
Dec 15th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. (*
  2. Foreach element in fifth do
  3. sum elements in second filtered by matching characters in first and
  4. subtract elements in fourth filtered by matching characters in third
  5. *)
  6.  
  7. module SOQN =
  8.  
  9. open System
  10.  
  11. let first = [|"A"; "B"; "C"; "D"; "E"; "F"; "G"; "H"; "I"; "J"|]
  12. let second = [|13.0; 17.0; 19.0; 23.0; 29.0; 0.0; 0.0; 0.0; 0.0; 0.0|]
  13. let third = [|"ABCD"; "ABCE"; "ABDE"; "ACDE"; "BCDE"|]
  14. let fourth = [|2.0; 3.0; 5.0; 7.0; 11.0|]
  15. let fifth = [|"ABC"; "ABD"; "ABE"; "ACD"; "ACE"; "ADE"; "BCD"; "BCE"; "BDE"; "CDE"|]
  16.  
  17. let sixth =
  18. [[for i in [0..fifth.Length - 1] do
  19. yield (sumFunc second first fifth.[i] -
  20. subtractFunc third fourth fifth.[i])]]
  21.  
  22.  
  23. // Expected Result: Sixth: [| 44.0; 46.0; 51.0; 39.0; 51.0; 53.0; 46.0; 51.0; 53.0; 53.0 |]
Add Comment
Please, Sign In to add comment