mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Merge branch 'master' of github.com:adambard/learnxinyminutes-docs
This commit is contained in:
commit
f276900d9b
@ -17,7 +17,6 @@ properly!
|
||||
The most requested languages are:
|
||||
|
||||
* Scala
|
||||
* Python
|
||||
* Javascript
|
||||
|
||||
... but there are many more requests to do "every language", so don't let that stop you.
|
||||
|
@ -59,10 +59,12 @@ and often automatically.
|
||||
(class false) ; Booleans are java.lang.Boolean
|
||||
(class nil); The "null" value is called nil
|
||||
|
||||
; If you want to create a literal list of data, use ' to make a "symbol"
|
||||
; If you want to create a literal list of data, use ' to stop it from
|
||||
; being evaluated
|
||||
'(+ 1 2) ; => (+ 1 2)
|
||||
; (shorthand for (quote (+ 1 2))
|
||||
|
||||
; You can eval symbols.
|
||||
; You can eval a quoted list
|
||||
(eval '(+ 1 2)) ; => 3
|
||||
|
||||
; Collections & Sequences
|
||||
|
@ -263,7 +263,32 @@ Just "hello"
|
||||
Just 1
|
||||
|
||||
----------------------------------------------------
|
||||
-- 8. The Haskell REPL
|
||||
-- 8. Haskell IO
|
||||
----------------------------------------------------
|
||||
|
||||
-- While IO can't be explained fully without explaining monads
|
||||
-- it is not hard to explain enough to get going
|
||||
|
||||
-- An IO a value is an IO action: you can chain them with do blocks
|
||||
action = do
|
||||
putStrLn "This is a line. Duh"
|
||||
input <- getLine -- this gets a line and gives it the name "input"
|
||||
input2 <- getLine
|
||||
return (input1++"\n"++input2) -- This is the result of the whole action
|
||||
|
||||
-- This didn't actually do anything. When a haskell program is executed
|
||||
-- an IO action called "main" is read and interprete
|
||||
|
||||
main = do
|
||||
putStrLn "Our first program. How exciting!"
|
||||
result <- action -- our defined action is just like the default ones
|
||||
putStrLn result
|
||||
putStrLn "This was all, folks!"
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------
|
||||
-- 9. The Haskell REPL
|
||||
----------------------------------------------------
|
||||
|
||||
-- Start the repl by typing `ghci`.
|
||||
|
Loading…
Reference in New Issue
Block a user