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

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

# TODO list in perl6

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

# I find a bug

24*(1+0.06)**384.0

24*(1+0.06)**384

The out put of rakudo is different as of 2012.07

# High Order Functions in Perl6

The following code mimic the code in text book in the part of high order functions.

the direct way

the abstact pattern

the abstract code

the perl6 implentment

TODO: add description

# Dailyprogrammer 80

The problem is from daily programmer

# EOPL assignment1

It is all about recursion……

;;this is test function (define (count1 x) (+ x 1)) (define count (lambda (x) (+ x 1))) ;;1. Define and test a procedure countdown that takes a natural number and returns a list of the natural numbers less than or equal to that number, in descending order. (define (countdown x) (if (zero? x) '(0) (cons x (countdown (- x 1))))) ;;(countdown 5) ;;2. Define and test a procedure insertR that takes two symbols and a list and returns a new list with the second symbol inserted after each occurrence of the first symbol. (define insertR (lambda (x y z) (if (null? z) z (if (eq? x (car z)) (cons (car z) (cons y (insertR x y (cdr z)))) (cons (car z) (insertR x y (cdr z))))))) ;;3.Define and test a procedure remove-1st that takes a a symbol and a list and returns a new list with the first occurrence of the symbol removed. (define remove-1st (lambda (x xs) (if (null? xs) xs (if (eq? x (car xs)) (cdr xs) (cons (car xs) (remove-1st x (cdr xs))))))) ;;5. filter (define filter1 (lambda (predict xs) (if (null? xs) xs (if (predict (car xs)) (cons (car xs) (filter1 predict (cdr xs))) (filter1 predict (cdr xs)))))) ;;; ( ) [ ] { } " , ' ` ; # | \ all of thest can not be used in the indentifers. ;;find function in haskell (define find1 (lambda (predict xs) (if (null? xs) xs (if (predict (car xs)) (car xs) (find1 predict (cdr xs))))))