Haskell Functional Programming

Haskell Functional Programming

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

take n list

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (26)

Section 1

(26 cards)

take n list

Front

Returns n values from the start of the list

Back

not ()

Front

Logical NOT

Back

x == y

Front

Compares two values and will return True or False

Back

reverse

Front

Reverses a list

Back

length list

Front

Returns the number of entities in a list

Back

x || Y

Front

Logical OR comparison

Back

tail list

Front

Returns all but the first item in the list

Back

min x y

Front

Returns the smallest value out of x and y

Back

foldr (-) 100

Front

Keeps taking each item from the list away from 100 starting from the right

Back

x && y

Front

Logical AND comparison

Back

max x y

Front

Returns the largest value out of x and y

Back

myLast :: [a] -> a myLast [x] = x myLast (_:xs) = myLast xs

Front

Function to return the last item in a list

Back

item or listA : listB

Front

Adds an item or list to the head of another list (prepending)

Back

name x = ...

Front

Declare a function with identifier name

Back

item or listA ++ listB

Front

Adds an item or list to the end of another list (appending)

Back

sumMe :: [Int] -> Int sumMe [] = 0 sumMe [x] = x sumMe (x:xs) = sumMe xs + x

Front

Function to sum a list

Back

ssp3 :: [Int] -> Int ssp3 xs = foldl (+) 0 (map (^2) xs)

Front

Function to

Back

[1..10]

Front

Returns 1 to 10 as it can perform pattern matching

Back

myLength :: [a] -> Int myLength [] = 0 myLength (_:xs) = 1 + myLength xs

Front

Function to return the length of a list

Back

foldl (-) 100

Front

Keeps taking each item from the list away from 100

Back

drop n list

Front

Removes n items from the start of a list

Back

succ x

Front

Will return the next integer after x

Back

reverseMe :: [a] -> [a] reverseMe [] = [] reverseMe [x] = [x] reverseMe (x:xs) = reverseMe xs ++ [x]

Front

Function to reverse a list

Back

head list

Front

Returns the first item of a list

Back

filter (>5) [1..10]

Front

Returns the numbers between 1 and 10 greater than 5

Back

name = [ "apple", "banana" ]

Front

Creates a list

Back