ç¶ç¶æ¸¡ãã¹ã¿ã¤ã«
rubyã®å ´åã¯ç¶ç¶ã®åã渡ãã«ãããã¯æ§æã使ãã¨ããæãã«æ¸ãããã ãªã
åããéä¹ã®ä¾ã
def fact(n) n==0 ? yield(1) : fact(n-1){|r|yield(n*r)} end fact(4){|r|puts r}
rubyã®å ´åã¯ç¶ç¶ã®åã渡ãã«ãããã¯æ§æã使ãã¨ããæãã«æ¸ãããã ãªã
åããéä¹ã®ä¾ã
def fact(n) n==0 ? yield(1) : fact(n-1){|r|yield(n*r)} end fact(4){|r|puts r}