Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Learn more about F# at http://fsharp.net
- // See the 'F# Tutorial' project for more help.
- let rec NWD = function
- | (0, n) -> n
- | (m, n) -> NWD(n % m, m)
- let skroc (l,m) =
- let znak = if l*m<0 then -1 else 1
- let al = abs l
- let am = abs m
- let d = NWD(al,am)
- in (znak * (al / d), am / d)
- let naString (l, m) =
- let znak = if l*m<0 then "-" else "" (* deklaracje wewnetrzne
- *)
- let al = abs l (* wart.bezw. = liczba nat.
- *)
- let am = abs m
- let d = NWD(al, am)
- in znak + (System.Convert.ToString(al / d))
- + "/" + (System.Convert.ToString(am / d))
- [<EntryPoint>]
- let main argv =
- let ( ++ ) (a, b) (c, d) = (a*d + b*c, b*d)
- let ( -- ) (a, b) (c, d) = (a*d - b*c, b*d)
- let ( ** ) (a, b) (c, d) = (a*c, b*d)
- let ( /./ ) (a, b) (c, d) = (a,b) ** (d,c)
- let ( == ) (a, b) (c, d) = (a*d = b*c)
- let a= (1,2) ++ (2,3)
- let b = 1./2. + 2./3. * 3./4.
- let c = (1, 2) ++ (2, 3) ** (3, 4)
- printfn "pierwsze %A" a
- printfn "drugie %A" b
- printfn "trzecie %A" c
- let q1 = (-2, 3);
- let q2 = (5, -10);
- let q3 = q1 ++ q2
- let q3_1 = q1 -- q2
- let q4 = q2 **q3
- let q5 = q4 /./ q3
- let q5_1 = q1 == q2
- let ns1 = naString q4
- let ns2 = naString q5
- printfn "q1= %A" q1
- printfn "q2= %A" q2
- printfn "q3= %A" q3
- printfn "q31= %A" q3_1
- printfn "q4= %A" q4
- printfn "q5= %A" q5
- printfn "q51= %A" q5_1
- printfn "ns1= %A" ns1
- printfn "ns2= %A" ns2
- 0 // return an integer exit code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement