タグ

2007年12月1日のブックマーク (3件)

  • CodeKata

    How do you get to be a great musician? It helps to know the theory, and to understand the mechanics of your instrument. It helps to have talent. But ultimately, greatness comes from practicing; applying the theory over and over again, using feedback to get better every time. How do you get to be an All-Star sports person? Obviously fitness and talent help. But the great athletes spend hours and ho

  • UK STUDIO - 後置記法のコードを添削してもらっちゃいました

    rubyneko - Re: UK STUDIO 後置記法での計算 後置記法での計算の添削に便乗してみた - チナミニ ujihisaさんとSixeightさんには感謝です。せっかくなんで添削してもらったコードを自分なりにちゃんと理解しときたいと思います。 ujihisaさんのコード class String def rpn expr = self.split(" ") stack = [] operators = %w[+ - * /] expr.each do |i| if operators.include? i stack = [calc(i, stack)] else stack < < i.to_i end end stack[0] end private def calc(operator, stack) stack.inject {|result, i| result._

  • 後置記法での計算の添削に便乗してみた - ちなみに

    UKさんの404 NotFound|ステキなウエディングをうじひささんがnowa サービス終了のお知らせにて添削されていたので、便乗して僕も書いてみた。まだうじひささんのコードは読んでない。いま僕が持ってる知識(当然マニュアルは参照した)を使って僕ならどう書くかという現段階の僕の答えです。 まず、元のコード class String def rpn @expr = self.split(" ") stack = Array.new @expr.each {|i| if i == "+" || i == "-" || i == "*" || i == "/" stack = calc(i, stack) else stack << i end } return stack[0] end private def calc(operator, stack) return Array(stack[

    後置記法での計算の添削に便乗してみた - ちなみに
    ukstudio
    ukstudio 2007/12/01
    参考にしますです。