How-do-i-show-results-of-two-functions-in-another-function

I have been as a part of a school assignment been coding a program on racket,which is similar to the tfl route planner. My objective is to create a function which takes the results from the two functions, for example for my first function I decide any random letter such as C for my starting and in my second function which is the same function expect it’s a final destination and I choose F.I want to be able to create function which after I compute both functions it updates the results into the new function,at this point when I run the new function it will print something like this “Your journey from C to F”

so I can begin the second phase which is to set a distance of 5 mins between each letter, and calculate he fastest route for example, from a to b is 5 min and a to c is 10 min.using set-intersection to find the quickest route I have been searching this on google and stack overflow, but they don't help. here is my code so far.

(define line1 (set "a" "b" "c" "d" "e"))

(define line2 (set "f" "g" "c" "h" "i"))

(define line3 (set "k" "i" "l" "m" "e"))

(printf "enter your current posistion")
(define exsists1 (λ (a)
  (cond
    ((empty? a) (error " you need to enter a starting location"))
    ((not (or (set-member? line1 a) (set-member? line2 a) (set-member? line3 a))) 
     (error "enter a location which exisits"))
    (else "enter your final destintation"))))

(define exsists2 (λ (b)
  (cond
    ((empty? b) (error " you need to enter a finishing location"))
    ((not (or (set-member? line1 b) (set-member? line2 b) (set-member? line3 b))) 
     (error "enter a location which exisits"))
    (else "plan your journey"))))

(Sorry to sound like clippy, here)

It sounds like you're trying to create a function. The design recipe in HtDP outlines a concrete set of steps for this process, starting with this:

  1. data definitions: definitions of new kinds of data required by your problems
  2. choose a name for your function, write down the kinds of arguments it accepts, and the kind of argument it returns. Write the first line of your function
  3. Write examples of how you might call your function, and what it might return.

Let's start with those. For more details, see www.htdp.org

4 Likes