mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 22:38:04 +02:00
Added definitions / examples
This commit is contained in:
parent
7a39159bdb
commit
b74de7b8da
8 changed files with 86 additions and 3 deletions
|
@ -0,0 +1,8 @@
|
|||
org 100h
|
||||
start:
|
||||
mov ax, 5522h
|
||||
mov cx, 1234h
|
||||
xchg cx,ax
|
||||
mov al, 0
|
||||
mov ah,4Ch
|
||||
int 21h
|
|
@ -0,0 +1,38 @@
|
|||
map :: (a -> b) -> [a] -> [b]
|
||||
map f [] = []
|
||||
map f (x:xs) = f x : map f xs
|
||||
----------
|
||||
|
||||
zipWith :: (a->b->c) -> [a]->[b]->[c]
|
||||
zipWith z (a:as) (b:bs)
|
||||
= z a b : zipWith z as bs
|
||||
zipWith _ _ _ = []
|
||||
----------
|
||||
|
||||
zip :: [a] -> [b] -> [(a,b)]
|
||||
zip = zipWith (,)
|
||||
----------
|
||||
|
||||
unzip :: [(a,b)] -> ([a],[b])
|
||||
unzip = foldr (\(a,b) ~(as,bs) -> (a:as,b:bs)) ([],[])
|
||||
----------
|
||||
|
||||
foldl :: (a -> b -> a) -> a -> [b] -> a
|
||||
foldl f z [] = z
|
||||
foldl f z (x:xs) = foldl f (f z x) xs
|
||||
----------
|
||||
|
||||
foldr :: (a -> b -> b) -> b -> [a] -> b
|
||||
foldr f z [] = z
|
||||
foldr f z (x:xs) = f x (foldr f z xs)
|
||||
----------
|
||||
|
||||
take :: Int -> [a] -> [a]
|
||||
take n _ | n <= 0 = []
|
||||
take _ [] = []
|
||||
take n (x:xs) = x : take (n-1) xs
|
||||
----------
|
||||
|
||||
splitAt :: Int -> [a] -> ([a],[a])
|
||||
splitAt n xs = (take n xs, drop n xs)
|
||||
----------
|
|
@ -0,0 +1,3 @@
|
|||
val list = List("USA", "Russia", "Germany")
|
||||
for(country <- list)
|
||||
println(country)
|
Loading…
Add table
Add a link
Reference in a new issue