Extend your language: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) (→{{header|6502 Assembly}}: Fixed a typo (not in the code)) |
(Realize in F#) |
||
Line 814: | Line 814: | ||
</pre> |
</pre> |
||
=={{header|F_Sharp|F#}}== |
|||
<lang fsharp> |
|||
// Extend your language. Nigel Galloway: September 14th., 2021 |
|||
type elsetf=TF |
|||
type elseft=FT |
|||
type elseff=FF |
|||
let elsetf,elseft,elseff=TF,FT,FF |
|||
let if2 n g tt (TF:elsetf)tf (FT:elseft)ft (FF:elseff)ff=match(n,g) with (true,true)->tt() |(true,false)->tf() |(false,true)->ft() |_->ff() |
|||
if2 (13<23) (23<42) (fun()->printfn "tt") |
|||
elsetf (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
if2 (13<23) (42<23) (fun()->printfn "tt") |
|||
elsetf (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
if2 (23<23) (23<42) (fun()->printfn "tt") |
|||
elsetf (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
if2 (23<13) (42<23) (fun()->printfn "tt") |
|||
elsetf (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
tt |
|||
tf |
|||
ft |
|||
ff |
|||
</pre> |
|||
Looking at some possible errors found by the compiler: |
|||
<lang fsharp> |
|||
if2 (13<23) (23<42) (fun()->printfn "tt") |
|||
elseff (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
This expression was expected to have type |
|||
'elsetf' |
|||
but here has type |
|||
'elseff' |
|||
</pre> |
|||
<lang fsharp> |
|||
if2 (13<23) (42<23) (fun()->printfn "tt") |
|||
elsetx (fun()->printfn "tf") |
|||
elseft (fun()->printfn "ft") |
|||
elseff (fun()->printfn "ff") |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
The value or constructor 'elsetx' is not defined. Maybe you want one of the following: |
|||
elsetf |
|||
elseft |
|||
elseff |
|||
</pre> |
|||
=={{header|Factor}}== |
=={{header|Factor}}== |
||
Not too hard, as long as you're not worried about choking to death on stack effects: |
Not too hard, as long as you're not worried about choking to death on stack effects: |