- Joined
- Jul 14, 2019
I've been implementing my own lisp recently having never used a lisp before, and I have been pleasantly surprised at the elegance of prefix notation, specifically how you can have an "operator" be N-nary rather than be limited to two operands with infix notation, so what would be an "add" operator in an infix expression, allowing only 2 operands and requiring parsing of precedence, in the world of prefix notation basically doubles as a sum function because you can have any arbitrary amount of operands, also you don't need to care about precedence because your program is already a syntax tree when you write it which is nice too.Distinguishing between operators and functions at all is niggerlicious.
I hate common lisp's boomer naming, so rather than do that, I went off my limited knowledge of lisp, which is basically just s-expressions and prefix notation and I figured out what features I wanted from there and named them how I wanted. deal with it. inb4 "cat" is boomer naming. Yes, but I like it so it gets a pass.
Code:
(def name "nigger rapist")
(print
// `cat` is string concatenation
(cat "hey " name ", you are a stupid nigger!\n"))
(def FACT_PATH "factorial.nig")
(println
(cat "Anyways, gonna load some external code from `" FACT_PATH
"`, then calculate the Nth factorial defined in the file."))
// works like source(1) in shell
(src FACT_PATH)
(print
(cat "computing " N_TO_COMPUTE "th factorial:\n"))
(println
(factorial N_TO_COMPUTE))
(println "Am I huwhite now, kiwibros?")
Code:
// factorial.nig
(def N_TO_COMPUTE 1000)
(def factorial
(fn (n)
(if (< n 2)
1
(* n (factorial (- n 1))))))
And running it with my NiggerLisp interpreter

Lisp truly is the white man's language
Lambdas are of course real nigga lambdas
Code:
(src "factorial.nig")
(def factorials
(fn (from to pred)
(if (< from to)
// do runs all the expressions contained within, but only returns the last expression's result
(do
(pred from (factorial from))
(factorials (+ from 1) to pred)))))
(def padprint
(fn (n f)
(if (< n 10)
(println (cat " " n ": " f))
(println (cat n ": " f)))))
(factorials 5 15 padprint)

This makes me want to go and fully learn a functional language. Any suggestions? From what I have read, people seem to like scheme and ocaml a lot.