The Science of Programming/SwayPresentations/Objects/Examples2

From Wikibooks, open books for an open world
< The Science of Programming‎ | SwayPresentations/Objects
Jump to: navigation, search

Examples

How about aspects?

Here's a stack:

   function stack()
       {
       var store = :null;
       
       function push(item)
           {
           store = cons(item,store);
           item;
           }
       function pop()
           {
           var item = car(store);
           store = cdr(store);
           item;
           }
       function empty?()
           {
           store == :null;
           }
       this;
       }
   

Next Previous Top