In a haskell

Esempi di codice

1
0

funzione di haskell

-- Functors are a class of data structure that "contain" a generic type
-- you can "inject" functions inside these functors with `fmap`

-- Applying a function "inside" of a functor will not change the structure
-- of the functor
-- e.g `fmap (\x -> x + 1)` [1..10] will not change the length of the list

-- Functors require an implentation of `fmap`
fmap :: Functor f => (a -> b) -> f a -> f b

-- and have to obey the functor laws:
-- fmap id = id
-- fmap (f . g) = fmap f . fmap g
0
0

in a haskell

take 1 $ filter even [1..10] 
-- = [2]

-- Same with:
take 1 (filter even [1..10])

Pagine correlate

Pagine di esempio simili

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
English
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................