Quantcast

Operator #

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Operator #

c8h10n4o2
What does # mean in this code ? (from Data.List)

findIndices p ls = loop 0# ls
                 where
                   loop _ [] = []
                   loop n (x:xs) | p x       = I# n : loop (n +# 1#) xs
                                      | otherwise = loop (n +# 1#) xs
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Operator #

Daniel Fischer


On Thu, Dec 9, 2010 at 8:31 PM, c8h10n4o2 <[hidden email]> wrote:

What does # mean in this code ? (from Data.List)


It's a "magic hash" denoting here on the one hand unboxed machine ints (0#) and on the other the constructor wrapping such a raw machine int to a Haskell boxed Int (I#). GHC uses the magic hash to mark raw unboxed stuff (which you'll rarely need to use). In the libraries, sometimes using the raw machine data types (Int#, Word#, Double#, Float# and a few more) is needed for better performance.

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Loading...