diff options
author | Adam <adam@adambard.com> | 2013-06-28 20:53:43 -0700 |
---|---|---|
committer | Adam <adam@adambard.com> | 2013-06-28 20:53:43 -0700 |
commit | aac147f3e930d8fabaaa79cac22ce87650cb8432 (patch) | |
tree | 29a19bb20aa57413185db3c4be911fda10a44422 | |
parent | 745760ff1860de4449b5ac7e540164e9645b3c0a (diff) |
Use Csharp syntax highlighting for fsharp
-rw-r--r-- | fsharp.html.markdown | 2 | ||||
-rw-r--r-- | haskell.html.markdown | 25 |
2 files changed, 17 insertions, 10 deletions
diff --git a/fsharp.html.markdown b/fsharp.html.markdown index 69c70bc6..5c54130d 100644 --- a/fsharp.html.markdown +++ b/fsharp.html.markdown @@ -15,7 +15,7 @@ The syntax of F# is similar to Python: If you want to try out the code below, you can go to [tryfsharp.org](http://www.tryfsharp.org/Create) and paste it into an interactive REPL. -```fsharp +```csharp // single line comments use a double slash (* multi line comments use (* . . . *) pair diff --git a/haskell.html.markdown b/haskell.html.markdown index a5a6117f..563674c9 100644 --- a/haskell.html.markdown +++ b/haskell.html.markdown @@ -89,7 +89,8 @@ last [1..5] -- 5 -- with a conditional [x*2 | x <- [1..5], x*2 > 4] -- [6, 8, 10] --- Every element in a tuple can be a different type, but a tuple has a fixed length. +-- Every element in a tuple can be a different type, but a tuple has a +-- fixed length. -- A tuple: ("haskell", 1) @@ -106,11 +107,13 @@ add a b = a + b -- Using the function add 1 2 -- 3 --- You can also put the function name between the two arguments with backticks: +-- You can also put the function name between the two arguments +-- with backticks: 1 `add` 2 -- 3 --- You can also define functions that have no characters! This lets you define --- your own operators! Here's an operator that does integer division +-- You can also define functions that have no characters! This lets +-- you define your own operators! Here's an operator that does +-- integer division (//) a b = a `div` b 35 // 4 -- 8 @@ -135,12 +138,13 @@ foo (x, y) = (x + 1, y + 2) map func [x] = [func x] map func (x:xs) = func x:(map func xs) --- Anonymous functions are created with a backslash followed by all the arguments. +-- Anonymous functions are created with a backslash followed by +-- all the arguments. map (\x -> x + 2) [1..5] -- [3, 4, 5, 6, 7] --- using fold (called `inject` in some languages) with an anonymous function. --- foldl1 means fold left, and use the first value in the array as the initial --- value for the accumulator. +-- using fold (called `inject` in some languages) with an anonymous +-- function. foldl1 means fold left, and use the first value in the +-- array as the initial value for the accumulator. foldl1 (\acc x -> acc + x) [1..5] -- 15 ---------------------------------------------------- @@ -210,7 +214,7 @@ haskell = if 1 == 1 then "awesome" else "awful" --- case statements: Here's how you could parse command line arguments in Haskell +-- case statements: Here's how you could parse command line arguments case args of "help" -> printHelp "start" -> startProgram @@ -280,3 +284,6 @@ qsort (p:xs) = qsort lesser ++ [p] ++ qsort greater ``` Haskell is easy to install. Get it [here](http://www.haskell.org/platform/). + +You can find a much gentler introduction from the excellent [Learn you a Haskell](http://learnyouahaskell.com/) + |