5 decimal places of pi

“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/


Min Stack II

# 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.

Min Stack

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……