From: peter.wood@... Date: 2000-11-29T20:16:55+09:00 Subject: [ruby-talk:6619] closures (rb vs lisp?) Hi I am trying to figure out how to do closures in Ruby. In CL I can do this : ------------------------------------------------------- (defun shop-list (the-list) #'(lambda (action item) (case action (buy (setf the-list (adjoin item the-list))) (cancel (setf the-list (remove item the-list))) (see the-list)))) --------------------------------------------------------- And use it like this: * (setf week1 (shop-list ())) => # * (funcall week1 'buy 'cornflakes) => (CORNFLAKES) * (funcall week1 'buy 'potatoes) => (POTATOES CORNFLAKES) * (setf week2 (shop-list ())) =># * (funcall week2 'buy 'beer) => (BEER) I have just started "Programming Ruby", and I know the answer is there somewhere. I need to use "blocks" and "proc". The Array class has all the methods I need for the list (uniq! etc) I just don't know how to set it out. Thanks in advance. Peter