 I have not had much time for my [Roguelike](https://steemit.com/programming/@woz.software/building-a-roguelike-in-f-from-scratch-take-items) so thought I would throw together a quick cheat sheet of some basic F# syntax to help people understand some of the code ``` // Declare value binding let unitValue = () // unit let anInt = 42 // int value let aString = "blah" // string value let aFloat = 4.2 // float value let aDouble = 4.2m // double value // Declare functions let noArgs () = 42 // No such thing as no arg function unit -> int let add1 x = x + 1 // One arg function let add x y = x + y // Two arg function // Generic functions let inline genAdd x y = x + y // Function calling let result0 = noArgs () // = 42 let result1 = add1 41 // = 42 let result2 = add 40 2 // = 42 // Error add takes ints as first use was ints //let error = add 4.0 5.0 // Can use for anything with + as inlined let intAdd = genAdd 5 6 let floatAdd = genAdd 5.0 6.0 // Partial application let anotherAdd1 = add 1 // = int -> int let result = anotherAdd1 41 // = 42 // Value piping let piped1 = 40 |> add 2 // = 42 let piped2 = add <| 2 <| 40 // = 42 // Tuples let tuple = (4, "2") // (int * string) let four = fst tuple // int let two = snd tuple // string let (first, second) = tuple // Extract both into bindings let (f, _) = tuple // Extract the first value let (_, S) = tuple // Extract the second value // Records type record = {id: int; name: string} let aRecord = {id = 5; name = "Bill"} let id = aRecord.id // = 5 let name = aRecord.name // = "Bill" let updated = {aRecord with name = "Bob"} // Unions type nullable = | Value of int | Null let aValue = Value 5 // Value of 5 let nothing = Null // Null (Not null as in C but type) // Pattern matching let extract x = match x with | Value y -> y | Null -> 0 let extractedValue = extract aValue // = 5 let extractedNull = extract nothing // = 0 ``` Feel free to ask any questions Happy coding Woz
author | woz.software |
---|---|
permlink | f-basic-syntax-cheat-sheet |
category | programming |
json_metadata | {"tags":["programming","computer","technology","howto","tutorial"],"image":["http://i.imgur.com/GB4RoBB.jpg"],"links":["https://steemit.com/programming/@woz.software/building-a-roguelike-in-f-from-scratch-take-items"],"app":"steemit/0.1","format":"markdown"} |
created | 2017-09-01 09:25:21 |
last_update | 2017-09-01 09:25:21 |
depth | 0 |
children | 6 |
last_payout | 2017-09-08 09:25:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.062 HBD |
curator_payout_value | 0.278 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,184 |
author_reputation | 2,321,910,395,519 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,533,866 |
net_rshares | 359,195,091,698 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
steemychicken1 | 0 | 313,654,241,854 | 100% | ||
drifter1 | 0 | 9,530,142,931 | 100% | ||
lloyddavis | 0 | 4,425,357,555 | 30% | ||
kkugel2 | 0 | 258,716,212 | 100% | ||
shantamcbain | 0 | 673,891,486 | 100% | ||
pilcrow | 0 | 27,531,198,510 | 50.51% | ||
qed | 0 | 3,121,543,150 | 100% | ||
alkasai | 0 | 0 | 100% |
Awesome! Nice job! That needs a resteem... And I'm waiting for the next Roquelike Tutorial ;)
author | drifter1 |
---|---|
permlink | re-wozsoftware-f-basic-syntax-cheat-sheet-20170901t093434147z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-01 09:34:33 |
last_update | 2017-09-01 09:34:33 |
depth | 1 |
children | 2 |
last_payout | 2017-09-08 09:34:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.001 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 93 |
author_reputation | 98,202,866,830,354 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,534,435 |
net_rshares | 6,072,153,650 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
woz.software | 0 | 6,072,153,650 | 100% |
Yep, things been getting busy at work. A re-write of our core product I have been working on for many many years ships November :O Big cognative load as 300000+ lines of C# and JS front end. Also finally planned our trip back to UK to see friends and family, not been home in 6 years. Also going to visit Chernobyl as a Detour, somewhere I have wanted to see for soooooo long So as soon as get a gap will dive back in.
author | woz.software |
---|---|
permlink | re-drifter1-re-wozsoftware-f-basic-syntax-cheat-sheet-20170901t095153651z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-01 09:51:54 |
last_update | 2017-09-01 09:53:06 |
depth | 2 |
children | 1 |
last_payout | 2017-09-08 09:51:54 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.024 HBD |
curator_payout_value | 0.008 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 421 |
author_reputation | 2,321,910,395,519 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,535,648 |
net_rshares | 9,364,880,337 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
drifter1 | 0 | 9,364,880,337 | 100% |
Oh, that was the reason! Good luck in your re-coding and have fun on your trip back home :)
author | drifter1 |
---|---|
permlink | re-wozsoftware-re-drifter1-re-wozsoftware-f-basic-syntax-cheat-sheet-20170901t120106381z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-01 12:01:06 |
last_update | 2017-09-01 12:01:06 |
depth | 3 |
children | 0 |
last_payout | 2017-09-08 12:01:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 91 |
author_reputation | 98,202,866,830,354 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,545,257 |
net_rshares | 0 |
Great job. Sorry I am not familiar with F# what language is it. My experience is limited to Perl, pascal, small amounts of python. The latter for control and monitoring systems.
author | shantamcbain |
---|---|
permlink | re-wozsoftware-f-basic-syntax-cheat-sheet-20170902t175247739z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-02 17:52:45 |
last_update | 2017-09-02 17:52:45 |
depth | 1 |
children | 1 |
last_payout | 2017-09-09 17:52:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.020 HBD |
curator_payout_value | 0.005 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 177 |
author_reputation | 1,455,168,455,192 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,670,730 |
net_rshares | 6,796,406,029 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
woz.software | 0 | 6,796,406,029 | 100% |
It is an ML based language but runs on .NET (Also mono so Linux and mac) Full static typing so everything you see knows the types and flags errors. Haskell has some roots in ML but then added all the category theory head spin stuff. Really like the language. Really terse but expressive. Take a look at my Building a Roguelike series and you will see it used in anger :)
author | woz.software |
---|---|
permlink | re-shantamcbain-re-wozsoftware-f-basic-syntax-cheat-sheet-20170902t215305264z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-02 21:53:06 |
last_update | 2017-09-02 21:53:06 |
depth | 2 |
children | 0 |
last_payout | 2017-09-09 21:53:06 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 375 |
author_reputation | 2,321,910,395,519 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,687,556 |
net_rshares | 719,798,482 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
shantamcbain | 0 | 719,798,482 | 100% |
good job follow u
author | yash0108 |
---|---|
permlink | re-wozsoftware-f-basic-syntax-cheat-sheet-20170902t082608458z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-09-02 08:26:12 |
last_update | 2017-09-02 08:26:45 |
depth | 1 |
children | 0 |
last_payout | 2017-09-09 08:26:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.018 HBD |
curator_payout_value | 0.005 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 17 |
author_reputation | 3,386,741,504,526 |
root_title | "F# Basic Syntax Cheat Sheet" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 13,628,161 |
net_rshares | 6,694,378,701 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
woz.software | 0 | 6,694,378,701 | 100% |