Created
April 2, 2014 00:24
-
-
Save liammclennan/9925787 to your computer and use it in GitHub Desktop.
Problem using F# match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this works | |
let makeImage bytes = | |
match Array.length bytes with | |
| 784 -> Image bytes |> Some | |
| _ -> None | |
// but this does not. The none branch is never used. | |
let makeImage bytes = | |
let numOfPixels = 784 | |
match Array.length bytes with | |
| numOfPixels -> Image bytes |> Some | |
| _ -> None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 14 is a typo I presume. You're naming the result of
Array.length bytes
instead of using the value you've assigned in line 12. The only way to make that work (that i'm aware of) is: