📅  最后修改于: 2021-01-01 04:35:50             🧑  作者: Mango
Symbol | Description |
---|---|
+(addition, plus) | It adds two values |
-(subtract, minus) | It subtracts two values |
*(multiplication, times) | It multiplies two values |
/(division, divided by) | It is used to divide |
%(modulus, mod) | It returns remainder of division operation |
**(exponentiation, to the power of) | It performs exponent operation |
module Arithmetic =
let add (a:int,b:int):int =
a+b
let sub (a:int,b:int):int =
a-b
let mul (a:int,b:int):int =
a*b
let div (a:int,b:int):int =
if b<>0 then
a/b
else 0
let modu (a:int,b:int):int =
a%b
open Arithmetic
let addition = add (10, 10)
let subtraction = sub (50,20)
let multiplication = mul (10,10)
let division = div (10,2)
let modulus = modu (10,3)
printfn "--------------------Result------------------"
printfn "sum = %d" addition
printfn "subtraction = %d" subtraction
printfn "multiply = %d" multiplication
printfn "division = %d" division
printfn "modulus = %d" modulus
输出:
--------------------Result------------------
sum = 20
subtraction = 30
multiply = 100
division = 5
modulus = 1
Symbol | Description |
---|---|
+(positive) | It applies on arithmetic expressions. It does not change sign of value |
-(negative,negation) | It applies on arithmetic expressions. It changes sign of value. |
Symbol | Description |
---|---|
=(equality, equals) | This is not an assignment operator. It is used only for comparison. This is a generic operator. |
>(greater than) | It is a generic operator |
<(less then) | It is a generic operator |
>=(greater than or equals) | It is a generic operator |
<=(less than or equals) | It is a generic operator |
<>(not equal) | It is a generic operator |
let comparisionOperator(a:int, b:int) =
if(ab) then
printfn "A is greater than B"
if(a=b) then
printfn "A is equal to B"
comparisionOperator (10, 20) // calling of function
输出:
A is less than B