1
0
Fork 0
pr3-ws202627/haskell/02-list-operations/aufgaben.md

25 lines
454 B
Markdown

x !! n
head $ drop n x
nthElement = curry (head . (uncurry drop))
Aufgabe 2 Vektormultipli (Skalarprodukt)
ghci> y = 1:8:9:7:8:14:[]
ghci> y
[1,8,9,7,8,14]
ghci> x = 9:8:25:14:63:[]
ghci> u = zip x y
ghci> w = sum$ map (\(x,y)->x*y)u
ghci> w
900
länge hallo ohne length
const 1 "hallo"
const 1 5
map (const 1) str
foldr (+) 0 $ map (const 1) str
paare von 2 natürlichen zahlen bis, die nicht gleich sind
[(a,b) | a <- [1..5], b <- [1..5], a /= b]