<commit_before>from atom import TRUE
from atom import FALSE
from atom import Symbol
from seq import Seq

class Lisp:
    SPECIAL = "()"

    """
    The original Lisp described by McCarthy in his 1960 paper describes the following function set:
    1.  `atom`    (/) done
    2.  `car`     (/) done
    3.  `cdr`     (/) done
    4.  `cond`
    5.  `cons`    (/) done
    6.  `eq`      (/) done
    7.  `quote`   (/) done

    http://www-formal.stanford.edu/jmc/recursive.html
    """
    def dummy(self, env, args):
        print("I do nothing, but you gave me: ")
        self.println(env, args)

    def cond(self, env, args):
        print("doing cond")
        print(args)
        return FALSE

    def eq(self, env, args):
        if len(args) > 2:
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(2, len(args)))

        if args[0].eval(env) == args[1].eval(env):
            return TRUE

        return FALSE

    def quote(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))

        return args[0]

    def car(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))

        first_elem = args[0].eval(env)

        if not isinstance(first_elem, Seq):
            raise ValueError("Function not valid on non-sequence type.")

        return first_elem.car()

    def cdr(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))<commit_msg>cond is going to require t and nil to be defined<commit_after>from atom import TRUE
from atom import FALSE
from atom import Symbol
from seq import Seq

class Lisp:
    SPECIAL = "()"

    """
    The original Lisp described by McCarthy in his 1960 paper describes the following function set:
    1.  `atom`    (/) done
    2.  `car`     (/) done
    3.  `cdr`     (/) done
    4.  `cond`
    5.  `cons`    (/) done
    6.  `eq`      (/) done
    7.  `quote`   (/) done

    http://www-formal.stanford.edu/jmc/recursive.html
    """
    def dummy(self, env, args):
        print("I do nothing, but you gave me: ")
        self.println(env, args)

    # (cond ((atom (quote foo)) (quote foo)) ((atom (quote (1 2))) (quote bar)) (t (quote baz)))
    def cond(self, env, args):
        for test in args:
            result = test.car().eval(env)

            print(result)

        return FALSE

    def eq(self, env, args):
        if len(args) > 2:
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(2, len(args)))

        if args[0].eval(env) == args[1].eval(env):
            return TRUE

        return FALSE

    def quote(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))

        return args[0]

    def car(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))

        first_elem = args[0].eval(env)

        if not isinstance(first_elem, Seq):
            raise ValueError("Function not valid on non-sequence type.")

        return first_elem.car()

    def cdr(self, env, args):
        if(len(args) > 1):
            raise ValueError("Wrong number of arguments, expected {0}, got {1}".format(1, len(args)))
{'fraction_non_alphanumeric': 0.1394751853964632, 'fraction_numerical': 0.01825442099258414, 'mean_word_length': 2.1998175182481754, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1396108', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1096, 'n_words': 360}