Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
KR#2
//F# Compiler for F# 4.0 (Open Source Edition), Mono 4.2.1 open System //описуємо структуру System.Console.WriteLine("Виберіть важливість критерією від 1 до 10: \n"); System.Console.WriteLine("Ціна: \n"); let p = Console.ReadLine()|>float System.Console.WriteLine("Дизайн: \n"); let di = Console.ReadLine()|>float System.Console.WriteLine("Потужність: \n"); let po = Console.ReadLine()|>float System.Console.WriteLine("Надійність: \n"); let re = Console.ReadLine()|>float //w let mutable c=0 let mutable array2 : double array = Array.zeroCreate 5 let mutable max=0.0 type Laptop = {Brand: string Price: double Design: double Power: double Reliability: double Num:int } let mutable laptop1 = { Brand = "Lenovo" Price = 4.7 Design= 5.2 Power = 8.15 Reliability = 6.8 Num=0 } let mutable laptop2 = { Brand = "Apple" Price = 9.8 Design= 8.0 Power = 4.70 Reliability = 9.77 Num=1 } let mutable laptop3 = { Brand = "Dell" Price = 9.25 Design= 6.66 Power = 8.70 Reliability = 9.42 Num=2 } let mutable laptop4 = { Brand = "Asus" Price = 5.1 Design= 4.68 Power = 4.2 Reliability = 5.90 Num=3 } let mutable laptop5 = { Brand = "Xiaomi" Price = 8.75 Design= 9.45 Power = 7.9 Reliability = 8.1 Num=4 } array2.[0]<- laptop1.Price*p+laptop1.Design*di+laptop1.Power*po+laptop1.Reliability*re array2.[1]<- laptop2.Price*p+laptop2.Design*di+laptop2.Power*po+laptop2.Reliability*re array2.[2]<- laptop3.Price*p+laptop3.Design*di+laptop3.Power*po+laptop3.Reliability*re array2.[3]<-laptop4.Price*p+laptop4.Design*di+laptop4.Power*po+laptop4.Reliability*re array2.[4]<-laptop5.Price*p+laptop5.Design*di+laptop5.Power*po+laptop5.Reliability*re for i in 0 .. array2.Length - 1 do if max < (array2.[i]) then max <- array2.[i] c<-i //створюємо ліст let lst = [laptop1; laptop2; laptop3; laptop4; laptop5] let testfun (t:Pullover) = match t with | Laptop when t.Num = c -> printf "%A" t | _ -> () //цикл по лісту for t in lst do testfun t
run
|
edit
|
history
|
help
0
Highly Modular FizzBuzz
F#: Basic Immutability vs. Mutability
Calculate distance between two GPS latitude-longitude points.
FizzBuzz without Modulo in F#
Average Square Error
Split list without mutable values
The wonders of F#
Musical Note Frequencies (Equal temperament)
Map.except
Give F# Some Love!