Comments on: Learning Python http://stephenwoods.net/2010/02/21/learning-python/ !important Wed, 03 Aug 2011 16:09:43 +0000 hourly 1 http://wordpress.org/?v=3.2.1 By: kellanhttp://stephenwoods.net/2010/02/21/learning-python/comment-page-1/#comment-45 kellan Wed, 12 May 2010 01:54:54 +0000 http://stephenwoods.net/?p=133#comment-45 <pre class="brush: javascript"> object Coin { val rand = new scala.util.Random() def toss() = { rand.nextBoolean() } }var heads = 0 var tails = 0 val range = 0.until(1000000) for (i <- range) { if (Coin.toss()) { heads += 1 } else { tails += 1 } }println("Heads: " + heads + " Tails: " + tails) </pre> object Coin { val rand = new scala.util.Random() def toss() = { rand.nextBoolean() } } var heads = 0 var tails = 0 val range = 0.until(1000000) for (i <- range) { if (Coin.toss()) { heads += 1 } else { tails += 1 } } println("Heads: " + heads + " Tails: " + tails) ]]> By: Stephenhttp://stephenwoods.net/2010/02/21/learning-python/comment-page-1/#comment-37 Stephen Sun, 21 Feb 2010 08:40:31 +0000 http://stephenwoods.net/?p=133#comment-37 You and I think alike without sleep. ;P You and I think alike without sleep. ;P

]]>
By: Luke Smithhttp://stephenwoods.net/2010/02/21/learning-python/comment-page-1/#comment-36 Luke Smith Sun, 21 Feb 2010 07:48:10 +0000 http://stephenwoods.net/?p=133#comment-36 Well, technically, done once after the loop shouldn't change the results much. For some reason (read: lack of sleep) I thought it was in the loop :) Well, technically, done once after the loop shouldn’t change the results much. For some reason (read: lack of sleep) I thought it was in the loop :)

]]>
By: Luke Smithhttp://stephenwoods.net/2010/02/21/learning-python/comment-page-1/#comment-35 Luke Smith Sun, 21 Feb 2010 07:45:32 +0000 http://stephenwoods.net/?p=133#comment-35 Did you try the js/node version without JSON.stringify? It's a far more complicated operation than just printing output. Did you try the js/node version without JSON.stringify? It’s a far more complicated operation than just printing output.

]]>