Create the same list, two different ways with the values 1,2,3,4
Front
list = [1,2,3,4]
list = 1:2:3:4:[ ] (needs to be {values :list}
Back
How to grab a number of elements from the front of a list?
Front
take # [list]
Back
How do you use shell commands while in haskell?
Front
:! [command]
Back
How to find highest number in a list?
Front
maximum [list]
Back
How to create a range that goes by 2, up to 50?
Front
numRangeName :: [Int]
numRangeName = [2,4..50]
Back
How to check if a list if empty?
Front
null [list]
Back
How to use init command?
Front
init displays all except last element and the command is init [list]
Back
How to use a function in a function using doubleMe and doubleUs?
Front
editor filename
doubleUs x y = doubleMe x + doubleMe y (function have high priority on PEMDAS)
Back
How does comparison work?
Front
compares the first element only unless equal, then it compares the next and if equal compares the next and so on...
Back
Describe basic structure for set builder notation
Front
[expression | values, conditions]
Back
How to get rid of elements from a list?
Front
drop # [list]
Back
How to index in a list?
Front
[list] !! { # } (starts at 0)
Back
How to use the head command?
Front
head displays first element and command is head [list]
Back
How to reload the program?
Front
:reload or :r
Back
What does read do? Also display command
Front
Reads in a string and another value and tries to perform an operation
(ex. read "3.4" + 4.0 = 7.4 or read "True" || false = True)
Back
How to make a list of pancake toppings with defined type?
Front
pancakes :: [String] ([[Char]] will work as well)
pancakes = ["Chocolate","Banana","Strawberry","Blueberry"]
Back
How to search through commands?
Front
:tab [letter] (the letter can be used to limit search to commands starting with letter)
Back
How to find the product of a list?
Front
product [list]
Back
How to check if an element in a list?
Front
ex. 4 `elem` [3,4,5,6] is true
ex. 4 `elem` [3,5,6] is false
Back
Create two functions:
Create "Square" that squares input with values 1-10
Create "Cube" that cubes input with values 1-10 and the cubed number is higher than 20
+ sum of 2 ints (2 + 3)
- difference of 2 ints (2 - 3)
x the product of 2 ints (3 * 2)
^ raise a base to a power (2^3)
Back
How to get a length of the list?
Front
length [list]
Back
how to zip two lists?
Front
list1 `zip` list2
Back
How to use tail command?
Front
tail displays all except head and command is tail [list]
Back
How to open up editor?
Front
editor filename extension
Back
How do you use prefix functions as infix?
Front
backticks ( 8 `div` 4)
Back
How to open up Haskell in terminal?
Front
ghci
Back
How to find the sum of a list?
Front
sum [list]
Back
Infix Boolean
Front
&& - and (True && True)
|| - or (True || False)
Back
How to use last command?
Front
last displays the last element in the list and command is last [list]
Back
Create a function that removes all lowercase letters from a word
Front
removeLower word = [ letter | letter <-word, letter `elem` [ 'A'..'Z']]
Back
How to clear the screen?
Front
:! clear
Back
Single line comment
Front
--
Back
How to load a file into haskell?
Front
:l filename
Back
How to tell what type a value is?
Front
:type <value> or :t
Back
Section 2
(11 cards)
Templates
Front
definition: pattern = result
Guard:
[SPACE] |expression = result
[SPACE] | otherwise = result
Where:
result where pattern = result
Let:Pattern = result in result
Case: expression of pattern = result
Back
Create a function fib that gives the Fibonacci number for an index input
Front
fib :: Int->Int
fib index
[space] index <= 1 = 0
[space] index == 1 = 1
[space] otherwise = (fib (index - 1)) + (fib (index - 2))