lunarised.com

Racketeering

I have recently been learning a lisp language, which I thought would be fun to talk about. It’s Racket, and I am again thanking my homie @tA for his continued support in learning this somewhat different language

Evaluation

Everything in racket is evaluated. This means you can do very mathematical looking functions, like the following

(define (quadPos a b c) (
    (/ 
    (+ (* b -1) (sqrt (- (* b b) (* 4 a c)) )) 
    (* 2 a))))

which is the quadratic formula, believe it or not… (for the + anyway)…

Everything surrounded by brackets is evaluated, which seems very odd at first, and causes a few head scratches every now and again, although after a lot of work, I think I finally understand it.

SICP ass book bro!

I have also been working through SICP in my space time (and also in some work time, cheers for that homies!!!), and Racket is the language I use the most there… Although, I shouldn’t say language, as part of Rackets feature set, is that you can have multiple languages defined inside Racket, including the SICP lang… which is a scheme variant that has been built so that SICP can be run correctly.

I have been finding SICP challenging to be honest… Especially since I managed to have a leak in my bottle, and grape juice soaked the pages! Somehow they aren’t stained though, So I will take my wins where I can get them!

More about Racket

Right, so aside from the long wait it took for racket to be approved to be put on my work machine… I’ve only been slightly frustrated with a few things! One of which being the lack of lists i have been writing whilst doing SICP. I don’t think ive so much as written a filter or map yet. Although I will show of my own implementation of both of those functions below! (Thanks tA again for the help!)

(define (myFilter f ls)
(if (null? ls)
'()
    (if  (f (car ls))
        (cons   
            (car ls)
            (myFilter f (cdr ls)))
        (myFilter f (cdr ls)
))))

(define (myMap f ls) 
(if (null?  ls) 
'()
(cons (f (car ls))
  (myMap f (cdr ls)))))

I un-ironically learnt so much from writing these functions, and it is kind of funny how they are 2 of the easiest functions to write in racket that actually do something! Unfortunately, I guess I will never use them as there are inbuilt map and filter functions, but it was fun none the less.

Will racket replace rust as my end goal General Purpose lang?

Short answer… No.

Long answer… I do really like writing in Racket. It’s a language that gets my head spinning and it sometimes makes me feel really smart (After a long period of feeling very dumb!!!)

Rust is still where my heart is, due to the fact its a fast and readable language with all the cool tools that I would like to learn how to use, so I can turn into a much better programmer than I am currently. Although Racket is helping me improve in how i think about functions and the program execution as a whole.


Keep your realities separate...

lunarised_