Skip to content

Commit 5ba7cdc

Browse files
authored
Merge pull request #125 from blorbb/patch-1
Fix whitespace and syntax highlighting and things
2 parents c11c08e + 2169348 commit 5ba7cdc

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

_chapters/haskell1.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ But there are definitely cons:
212212

213213
The Haskell way of defining Lambda (anonymous) functions is heavily inspired by [Lambda Calculus](/lambdacalculus/), but also looks a bit reminiscent of the JavaScript arrow syntax:
214214

215-
```haskell
215+
```none
216216
JavaScript
217217
x=>x
218218
@@ -244,12 +244,12 @@ main = putStrLn $ y ("circular reasoning works because " ++)
244244

245245
Consider the following pseudocode for a simple recursive definition of the Quick Sort algorithm:
246246

247-
```lambdacalc
247+
```none
248248
QuickSort list:
249249
Take head of list as a pivot
250250
Take tail of list as rest
251251
return
252-
QuickSort( elements of rest < pivot ) ++ (pivot : QuickSort( elements of rest >= pivot ))
252+
QuickSort( elements of rest < pivot ) ++ (pivot : QuickSort( elements of rest >= pivot ))
253253
```
254254

255255
We’ve added a bit of notation here: `a : l` inserts a (“cons”es) to the front of a list `l` ; `l1 ++ l2` is the concatenation of lists `l1` and `l2`.
@@ -367,14 +367,13 @@ fibs n = fibs (n-1) + fibs (n-2)
367367
### if-then-else
368368

369369
```haskell
370-
If <condition> then <case 1> else <case2>
370+
if <condition> then <case 1> else <case 2>
371371
```
372372

373373
just like javascript ternary if operator: `<condition> ? <case 1> : <case 3>`
374374

375375
```haskell
376-
fibs n = if n==0 then 1 else if n==1 then 1 else fibs (n-1) + fibs (n-2)
377-
376+
fibs n = if n == 0 then 1 else if n == 1 then 1 else fibs (n-1) + fibs (n-2)
378377
```
379378

380379
### Guards
@@ -385,8 +384,7 @@ Can test Bool expressions (i.e. not just values matching as in pattern matching)
385384
fibs n
386385
| n == 0 = 1
387386
| n == 1 = 1
388-
|otherwise = fibs (n-1) + fibs (n-2)
389-
387+
| otherwise = fibs (n-1) + fibs (n-2)
390388
```
391389

392390
### case
@@ -395,7 +393,7 @@ fibs n
395393
fibs n = case n of
396394
0 -> 1
397395
1 -> 1
398-
otherwise -> fibs (n-1) + fibs (n-2)
396+
_ -> fibs (n-1) + fibs (n-2)
399397
```
400398

401399
</div>

0 commit comments

Comments
 (0)