JavaScript Fable: F# |> Js

chenge · April 23, 2021 · Last by linlinda replied at November 03, 2023 · 463 hits

基于 F#,强类型函数语言。感觉不错,代码清晰易读。前端有福了。

体验一下:

type Face = Ace | King | Queen | Jack | Number of int
type Color = Spades | Hearts | Diamonds | Clubs 
type Card = Face * Color

let aceOfHearts = Ace,Hearts
let tenOfSpades = (Number 10), Spades

match card with 
| Ace, Hearts -> printfn "Ace Of Hearts!"
| _, Hearts -> printfn "A lovely heart"
| (Number 10), Spades -> printfn "10 of Spades"
| _, (Diamonds|Clubs) -> printfn "Diamonds or clubs"
// warning: Incomplete pattern matches on this expression.
// For example, the value '(_,Spades)' may indicate
// a case not covered by the pattern(s).

https://fable.io

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.