Difference between revisions of "PreludeTour"
From HaskellWiki
m (Reverted edits by Tomjaguarpaw (talk) to last revision by Bjpop) 

(6 intermediate revisions by 2 users not shown)  
Line 2:  Line 2:  
−  ;'''abs''':  +  ;<span id="abs">'''abs'''</span>: 
{ border="0" cellpadding="4"  { border="0" cellpadding="4"  
    
Line 23:  Line 23:  
}  }  
−  ;'''all''':  +  ;<span id="all">'''all'''</span>: 
{ border="0" cellpadding="4"  { border="0" cellpadding="4"  
    
 ''type:''  <hask>all :: (a > Bool) > [a] > Bool</hask>   ''type:''  <hask>all :: (a > Bool) > [a] > Bool</hask>  
    
−   ''description:''   +   ''description:''  Applied to a predicate and a list, returns True if all elements of the list satisfy the predicate, and False otherwise. Similar to the function [[#any]]. 
    
 ''definition:''   ''definition:'' 
Latest revision as of 15:19, 6 February 2021
A Tour of the Haskell Prelude
 abs
type:  abs :: Num a => a > a

description:  returns the absolute value of a number. 
definition:  abs x
 x >= 0 = x
 otherwise = x

usage:  Prelude> abs (3) 3 
 all
type:  all :: (a > Bool) > [a] > Bool

description:  Applied to a predicate and a list, returns True if all elements of the list satisfy the predicate, and False otherwise. Similar to the function #any. 
definition:  all p xs = and (map p xs)

usage:  Prelude> all (<11) [1..10] True Prelude> all isDigit "123abc" False 