Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The LISP

Name: Anonymous 2010-10-12 9:18

Why is the function car not called first-of?

Why is the function cdr not called last-of?

Because.... post a comment with the answer, faggot.

Name: Anonymous 2010-10-13 23:17

FIOC Teniou

Name: Anonymous 2010-10-13 23:39


public final class Cons {
    /** extensive javadoc omitted for brevity... */
    private Object car;
    private Object cdr;
    public Object getFirstElementOfList() { return car; }
    public Object getTailOfList() { return cdr; }
    public void setFirstElementOfListBang...

Name: Anonymous 2010-10-14 0:10

(defun (first car))
(defun (last cdr))

Name: Anonymous 2010-10-14 1:29

>>42
Terrible!

Name: Anonymous 2010-10-14 2:15

>>43
What do you call cdadr?

Name: Anonymous 2010-10-14 2:50

>>45
You have never used cdadr in your life.

Name: Anonymous 2010-10-14 3:56

>>45,45
(defun (last-of-first-of-last cdadr))

Name: Anonymous 2010-10-14 12:02

(= (first-of) car)

(= (last-of xs)
    (if (null? (cdr xs))
        (first-of xs)
        (last-of (cdr xs)))

Name: Anonymous 2010-10-14 12:57

>>48
Hello, Paul Graham

Name: Anonymous 2010-10-14 15:55

>>45
eaweeawest

Name: Anonymous 2010-10-14 15:57

my other west is a wdst

Name: Anonymous 2010-10-14 16:50

ConsGetter cadr = ConsGetterFactory.makeConsGetterFromXMLString("<!DOCTYPE consgetter PUBLIC \"-//LISP//DTD CONSGETTER 1.0\"  \"http://www.lisp.org/lisp/lisp/DTD/consgetter.dtd\">" +
        "<consgetter> <elementgetter> <element>cdr</element> <!-- get rest of elements --> </elementgetter> <elementgetter> <element>car</element> <!-- get first element --> </elementgetter> </consgetter>");

Object myObject = cadr.apply(myCons);

Name: Anonymous 2010-10-14 17:00

I just puked a little inside.

Name: Anonymous 2010-10-14 19:26

>>52
You should update your ConsGetterFactory to support generics.

Name: JLISP 2010-10-14 21:07

package java.util.lisp;

import java.lang.reflect.*;
import java.util.ArrayList;
import javax.script.*;

public class List {
    private Node head;
   
    public List(Object head) {
        this.head = new Node(head);
    }
   
    public Object car() {
        if (head == null)
            throw new IllegalStateException();
        else
            return head;
    }
   
    public List cdr() {
        Node newHead = new Node(this.head);
        Node prev, next, newPrev, newNext;
        for (    prev = this.head, next = this.head.next;
                next != null;
                prev = prev.next, next = next.next) {
            newPrev = new Node(prev.object);
            newNext = new Node(next.object);
            newPrev.next = newNext;
        }
        return new List(newHead);
    }
   
    public static Object eval(String expression) {
        try {
            return new ScriptEngineManager(List.class.getClassLoader()).getEngineFactories().get(0).getScriptEngine().eval(expression);
        } catch (ScriptException e) {
            e.printStackTrace();
            return null;
        }
    }
   
    public static void apply(Method method, List[] arguments) {
        try {
            method.invoke(null, (Object[]) arguments);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

class Node {
    public Object object;
    public Node next;
   
    public Node(Object object) {
        this.object = object;
    }
}

Name: Anonymous 2011-02-04 17:13


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List