“Given that Pi can be estimated using the function 4 * (1 – 1/3 + 1/5 – 1/7 + …) with more terms giving greater accuracy, write a function that calculates Pi to an accuracy of 5 decimal places.” http://programmers.blogoverflow.com/2012/08/20-controversial-programming-opinions/
# last time, I build a min stack using perl6’s class.
# the problem is that the perl6 already have pop, push, min method.
# so, to solve the problem of name conflict, I have to rename the name.
# but there is another solution.
# use the multi instead of method.
The problem: Min Stack
Design a data structure that provides push and pop operations, like a stack, plus a third operation that finds the minimum element. All three operations must perform in constant time. You may assume that all elements are distinct.
Use perl6’s class to implement
TODO: use multi……
1 -TODO list in perl6
1.1 basic function
1.2 interact with the outside;
1.2.1 dispatch-using hash
1.2.2 dispathc-using multi
The out put of rakudo is different as of 2012.07