Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

Java Cons class

Very simple Cons class for Java

public class Cons<T,U>
{
    private T car;
    private U cdr;

    public Cons( T carArg, U cdrArg )
    {
        car = carArg;
        cdr = cdrArg;
    }

    public T getCar(){ return car; }
    public U getCdr(){ return cdr; }
}

car cdr cons from little LISPer

// description of your code here

(define cons
 (lambda (u v)
   (lambda (b)
     (cond (b u)
     (#t v)))))
(define lunch (cons 'apple '()))
(define car (lambda (l) (l #t)))
(define cdr (lambda (l) (l #f)))


« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS