So in both my Learn to Program: The Fundamentals and my Introduction to Systematic Programming – Part One they introduce the concept of design recipes – basically a step by step way to write certain programming features, like functions for example.
So I wanted a way to recall these recipes within the shell so in the beginning I can always follow the recipe when I’m designing, in this case, functions.
So in python, it was easy, just created my own module and wrote the following functions (one expandable one so when I Learn more recipes I can add them in, and a second one for immediate use):
def recipe(n):
if n == “htdf”:
print(“Step One: Examples”)
print(“Step Two: Type Contract”)
print(“Step Three: Header”)
print(“Step Four: Description”)
print(“Step Five: Body”)
print(“Step Six: Test”)
else:
return “”
def htdf():
print(“Step One: Examples”)
print(“Step Two: Type Contract”)
print(“Step Three: Header”)
print(“Step Four: Description”)
print(“Step Five: Body”)
print(“Step Six: Test”)
But I was having trouble in Racket(BSL), although I cheated a bit by using an image, it doesn’t really work as a function… this is what I have so far but I haven’t been able to emulate what I did in Python in the Racket(BSL) shell DrRacket:
(define (RECIPE n)
(if (string=? n “HTDF”)
[I put a jpeg of the receipt in point for here]
“false”))
Now the problem with my cheat is that I can’t call the function remotely, and have been using the (require module_name) that loads it right at the beginning and not as a callable function.
So if anyone has any ideas on how to replicate what I’ve done in python in racket(BSL), I’m all ears!