Skip to content

Instantly share code, notes, and snippets.

@celsojr
Created October 8, 2017 19:26
Show Gist options
  • Save celsojr/e3a61c2136d87f145b1510fb8fae0f94 to your computer and use it in GitHub Desktop.
Save celsojr/e3a61c2136d87f145b1510fb8fae0f94 to your computer and use it in GitHub Desktop.
open System
let (<->) x y = 2 * x + y = 1
let a = [ -1..5 ];; let b = [ -3..8 ];;
let axb = a |> List.collect (fun c -> b |> List.map (fun d -> c,d))
|> List.choose (fun (a,b) ->
match (a,b) with
| x when a <-> b -> Some(a,b)
| _ -> None)
let imr = axb |> List.map (fun (a,b) -> b)
[<EntryPoint>]
let main argv =
Console.OutputEncoding <- System.Text.Encoding.UTF8
printfn "Relação R(A,B) = { %s }" (axb |> List.map string |> String.concat "; ")
printfn "Única alternativa correta: Im(R) = { %s }" ((List.sort imr) |> List.map string |> String.concat "; ")
0 // return an integer exit code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment