# RYAN'S WEBSITE

Just something small and tiny.

Held by Ryan Ruoshui Yan.

Here is the world of a nerdy guy.

Visited:

Disclaimer: The notes below are fully/partially NOT created by myself. They are from slides and/or wikipedia and/or textbook. The purpose of this post is simply to learn and review for the course. If you think something is inappropriate, please contact me at “ryan_yrs [at] hotmail [dot] com” immediately and I will remove it as soon as possible.

### Compiled

• Haskell is compiled when loaded into GHCi, rather than simply interpreted as in Racket.

.hs

### How to import

``````:load

alias :l functions
-- ??
``````

### Comment

``````-- This is a comment
``````

### Boolean

``````True
False
``````

### Null

• ()
• It is called “unit”

### cons

``````1:[2,3]
``````

### Functions

• max
• Get max
• Get 1st item in the list (= first in Racket)
• tail
• Get 2nd to last items in the list (= rest in Racket)
• length
• Get len of list
• take n
• Get 1st n items in the list
• ++ (Infix)
• Concatenation of List

### Create function

``````double x = x + x
sumOfSquares x y = x * x + y * y
abs x = if x >= 0 then x else -x
-- Does not work if it is negative?
``````

### Lambda Expression

``````(\x -> x + x) 4
``````

### Pattern Matching

• Keyword: comment
• Symbol
• Represents everything: _

### cons Operator

• RIGHT-associative
• (x:y:rest) = (x:(y:rest))

### Local Binding

• Keyword: letin

### Infix Operators

``````-- Standard infix operator.
-- The real name of the + operator is (+).
-- The "(" and ")" are used to signal that
-- the function is meant to be used as infix.
1 + 2
-- or
(+) 1 2

-- Use backticks ‘...‘ to use binary functions as infix.
let add x y = x + y

let (+-+) x y = 3 * x + 4 * y
(+-+) 1 2
1 +-+ 2
``````

### Type of Expression

``````:t
``````
RECENT

## PHP Notes

How to embed PHP? Default<?php ...;?> Simplified (Need to be turned on)<? ?><?= ?><% %>How to print?echo "Hello World";// Note: Can use HTML tags insideecho "<br>";How to create var?\$var = "Hello";// Note: Can us...…

MORE
EARLIER

## Artificial Intelligence Notes

Notes for CSC384Disclaimer: The notes below are fully/partially NOT created by myself. They are from slides and/or wikipedia and/or textbook. The purpose of this post is simply to learn and review for the course. If you think something is inapprop...…

MORE