#haskell - Sun 11 Mar 2007 between 00:00 and 00:03



sorear> log10 $ 26^8
lambdabotNot in scope: `log10'
narain> log 10
sorear> log 10
lambdabot2.302585092994046
narain> log (26^8) / log 10
lambdabot11.319786783766544
sorearso, more stars.
barely
dons?pretty let x = 1 ; y = 2 in x + y -- we ue it here, desp.
lambdabot"Unterminated end-of-line comment" at column 26
heatsinkfuzan, there are some tricks to count bits in an integer fast. The straightforward way is just to loop (shift right 1; if odd then increment count)
despdons: thanks
fuzanheatsink: yah, that way's pretty obvious.
chessguylet's see, what other good questions were there? this was a good one, "if you want to keep a whole collection of ordered elements in sorted order, but be able to add to and delete from it in log n time, what data structure would you use?"
despdons: I'm a real Haskel n00b; can you tell me how to feed a file into the pretty printer?
soreari'm familiar with the smasher
dons?pretty let x = 1 ; y = 2 in x + y
lambdaboti = let x = 1
y = 2
in x + y
narainfuzan,heatsink: there's a trick to do it in O(no of on bits)
donsdesp, yep. hang on ....
narainwhich is ridiculously pointless
donsdesp, http://www.haskell.org/haskellwiki/Indent
lambdabotTitle: Indent - HaskellWiki
despdons: thanks
fuzannarain: not if you had HUGE integer sizes.
donsdesp, see sectoin 1.4
narainfuzan: ok, here goes then
donsnote you'll need to get haskell-src from hackage
?where hackage
lambdabothttp://hackage.haskell.org/packages/archive/pkg-list.html
narainn & (n - 1) is 0 iff n is 0 or a power of two
for unsigned n
so... hmm how did it go after that
sorear> let smash x = x .&. 0x55555555 + ((x `shiftR` 1) .&. 0x55555555) ; foo = smash.smash.smash.smash.smash in foo 100 -- narain, 20 arith ops and 0 conditional branches
lambdabotAdd a type signature
sorear> let smash x = x .&. 0x55555555 + ((x `shiftR` 1) .&. 0x55555555) ; foo = smash.smash.smash.smash.smash in foo (100 :: Int32) -- narain, 20 arith ops and 0 conditional branches
lambdabot84

Page: 2 9 16 23 30 37 44 51 58 65 72 79 

IrcArchive