--head [1,2,3,4] -- vraca glavu liste --tail [1,2,3,4] --vraca rep liste --f-ja se definise -- naziv_fje arg1 arg2 arg3... = {telo funkcije} double x = x+x doublesum x y = x*x + y*y --double je tipa Int->Int --prilikom poziva "take double 2 [1,2,3,4,5]" --koji tip prihvata take? --Int->Int->Int->[a] --pravilno je " take (double 2) [1,2,3,4,5]" somefunc x y = 3*y2 + x*y2 where y2 = y*y xs1 = [1,2,3,4,5] last1 xs = xs !! (length xs - 1) last2 xs = head (reverse xs) init1 xs = take (length xs -1) xs init2 xs = reverse (drop 1 (reverse xs)) --provera tipova --Main> :type True --True :: Bool --Main> :type 4 --4 :: Num a => a --Main> :type 4.5 --4.5 :: Fractional a => a --Main> :type pi --pi :: Floating a => a --Main> :type xs1 --xs1 :: [Integer] --[("Marko",9.8),("Ivana", 9.7)] scalarm :: (Int,Int,Int)->(Int,Int,Int)->Int scalarm (x1,y1,z1) (x2,y2,z2) = x1*x2+y1*y2+z1*z2 --currying --Main> (scalarm (1,2,3)) (4,5,6) --32 --Main> map (scalarm (1,2,3)) [(2,3,4),(5,6,7)] --[20,38]