gist-id: cd76ef36afbe36e7a65f
- یه برگه تقلب خوب برای هسکل
- [http://www.seas.upenn.edu/~cis194/spring13/](Introduction to Haskell-Spring 2013)
- bitemyapp/learnhaskell
- A Haskell CheatSheet in PDF and literate source formats.
- Introduction to Haskell/ University of Virginia CS 1501 Lectures Spring 2013
Haskell is a purely functional, lazy, statically typed programming language.
- Functions are values
- Values never change
- سخت نیست بلکه متفاوت است.
- سی - مهندسین
- جاوا- کسب-و-کاربر
- هسکل- ریاضیات
posOrNeg x =
if x >= 0
then "Positive"
else "Negative"
All Haskell functions are pure
- Cannot modify state
- Cannot depend on state
- Given the same arguments, always returns the same output
- print to console > Note pure
- Read file -> Not pure
- Compute the length of a list -> pure
- get the current time -> Not pure
- get a random number -> Not pure
pow2 n =
if n == 0
then 1
else 2 * ( pow2 (n-1) )
repeatString str n =
if n == 0
then ""
else str ++ ( repeatString str (n-1))
x = [1,2,3]
empty = []
y = 0 : x
x' = 1 : (2 : (3 : [] ) )
x'' = 1 : 2 : 3 : []
`` [1, 2, 3] ++ [4, 5] "hello " ++ "world"
## homogenous lists
error = [1, "hello", 2]
* head
* tail
* null
# Strings
str = "abcde" str` = 'a' : 'b' : 'c' : 'd' : 'e' : []
# تاریخچه