Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

advertising

related pastes to tag 'haskell'

868533 - RayNbow: lazy haskell
  1. <acura> @src null
  2. <lambdabot> null []     = True
  3. <lambdabot> null (_:_)  = False
  4. * phlpp has quit IRC ("leaving")
  5. <BMeph> > let f a b = a* (a+b) in f 0 0
  6. <lambdabot>  0
  7. * swiert has joined #haskell
  8. <RayNbow> hmm, why is the second pattern (_:_) and not just _?
  9.  
859696 - RayNbow: haskell sort naive merge
  1. module Main where
  2.  
  3.  
  4.  
  5. mergesort :: Ord a => [a] -> [a]
  6. mergesort []  =  []
  7. mergesort [x][x]
  8. mergesort xs  =  merge (mergesort xs1) (mergesort xs2)
  9.  
859068 - RayNbow: haskell sort naive merge
  1. module Main where
  2.  
  3.  
  4.  
  5. mergesort :: Ord a => [a] -> [a]
  6. mergesort []  =  []
  7. mergesort [x][x]
  8. mergesort xs  =  merge (mergesort xs1) (mergesort xs2)
  9.  
854170 - Sets and Monads: set haskell monad
  1. <RayNbow> hmm... I was wondering... [] is an instance of the Monad class... would it be useful to make other collection types (for example, Data.Set) also an instance of the Monad class?
  2. <Cale> RayNbow: If it were possible, Set would be an instance of Monad
  3. <Cale> RayNbow: The problem is that in order to implement bind and/or return, you need an instance of Ord for your element type, which isn't guaranteed by either of those.
  4. <Cale> :t (>>=)
  5. <lambdabot> forall (m :: * -> *) a b. (Monad m) => m a -> (a -> m b) -> m b
  6. <RayNbow> why would you need Ord?
  7. <Cale> (nothing here says that a or b will have an instance of Ord)
  8. <Cale> Because in order to build a Data.Set, which is really a binary tree structure, you need to have an ordering on the elements. That's how it gets its efficiency.
  9.  
fantasy-obligation
fantasy-obligation