updates to cs194 + language overview
This commit is contained in:
		
							
								
								
									
										83
									
								
								haskell/courses/upenn_cs194/week_1.page
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								haskell/courses/upenn_cs194/week_1.page
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
---
 | 
			
		||||
title: Week One Notes
 | 
			
		||||
toc: no
 | 
			
		||||
format: markdown
 | 
			
		||||
...
 | 
			
		||||
 | 
			
		||||
# Week One - Haskell Basics
 | 
			
		||||
 | 
			
		||||
## What Is Haskell?
 | 
			
		||||
 | 
			
		||||
  * Created in late 1980s by academics
 | 
			
		||||
  * Functional
 | 
			
		||||
  * Pure
 | 
			
		||||
  * Lazy
 | 
			
		||||
  * Statically Typed
 | 
			
		||||
 | 
			
		||||
## Course Themes
 | 
			
		||||
 | 
			
		||||
  * Types
 | 
			
		||||
  * Abstraction
 | 
			
		||||
  * Wholemeal Programming
 | 
			
		||||
 | 
			
		||||
## Literate Haskell
 | 
			
		||||
 | 
			
		||||
  * Only lines preceded by '>' are code
 | 
			
		||||
  * All other lines are comments
 | 
			
		||||
 | 
			
		||||
## Declarations of Variables
 | 
			
		||||
 | 
			
		||||
~~~ {.haskell}
 | 
			
		||||
x :: Int
 | 
			
		||||
x = 3
 | 
			
		||||
~~~
 | 
			
		||||
 | 
			
		||||
  * Declares a variable `x` of type `Int`
 | 
			
		||||
  * Defines the value of the variable `x` to be `3`
 | 
			
		||||
  * `=` is *definition*, not *assignment*
 | 
			
		||||
  * variables are just names for values
 | 
			
		||||
 | 
			
		||||
## Basic Types
 | 
			
		||||
 | 
			
		||||
  * `Int` - Machine-sized integers
 | 
			
		||||
  * `Integer` - Arbitrary-precision integers
 | 
			
		||||
  * `Double` - Double-precision floating point
 | 
			
		||||
  * `Bool` - Booleans
 | 
			
		||||
  * `Char` - Unicode characters
 | 
			
		||||
  * `String` - Lists of characters with special syntax
 | 
			
		||||
 | 
			
		||||
## GHCi
 | 
			
		||||
 | 
			
		||||
  * A Haskell Read Eval Print Loop (REPL)
 | 
			
		||||
  * `:load` - load a haskell file
 | 
			
		||||
  * `:reload` - reload the file
 | 
			
		||||
  * `:type` - return the type of an expression
 | 
			
		||||
  * `:?` - give a list of commands
 | 
			
		||||
 | 
			
		||||
## Arithmetic
 | 
			
		||||
 | 
			
		||||
  * Infix operators, `+`, `-`, `*`, `\`, `^`
 | 
			
		||||
  * Negation needs parens: `(-3)`
 | 
			
		||||
  * `div` for integer division
 | 
			
		||||
  * `mod` for integer remainder
 | 
			
		||||
  * Backticks turn named functions to infix operators
 | 
			
		||||
 | 
			
		||||
## Boolean Logic
 | 
			
		||||
 | 
			
		||||
  *
 | 
			
		||||
 | 
			
		||||
## Defining Basic Functions
 | 
			
		||||
 | 
			
		||||
## Pairs
 | 
			
		||||
 | 
			
		||||
## Using Functions, Multiple Arguments
 | 
			
		||||
 | 
			
		||||
## Lists
 | 
			
		||||
 | 
			
		||||
## Constructing Lists
 | 
			
		||||
 | 
			
		||||
## Functions on Lists
 | 
			
		||||
 | 
			
		||||
## Combining Functions
 | 
			
		||||
 | 
			
		||||
## A Word About Error Messages
 | 
			
		||||
		Reference in New Issue
	
	Block a user