I am asking this question as i am struggling to use sets and i would like to better understand how to tackle this goal .My goal here is to to
- write a function which sorts the union of all my three sets in alphabetical order.
- using the same function,i want to define a count sequence - meaning as an example,i have 12 elements as whole in my union of the sets,so then using these set methods set-count, set-first, set-rest,i want the letters to be counted in this order,so "a" belongs to first and "b" to second.so essentially racket is reading each letter as a number e,g "a" as 1 and so on.
- lastly,depending on which two letters i choose from my function below - the set methods should be applied to check the number of each letter.e,g if i choose "a" and "d", then it should be 1 and 4.i also would like know how to create a sequence where there +5 is added depending on the user selection,so from "a" to "b" is 5 and from "a" to "c" is 10,this is really a sequence of adding +5 to reach the intended letter.As a final output (example),i would like to see something like this ("your journey between a and c is 10 mins")
(this function is a combination of two function applied in this one function called journey" this is where i want my function to run.)
(define journey (λ (a b ) #this is the function where i want to compute the above.
(exsists1 a) (exsists2 b)))
(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 final location"))
((not (or (set-member? line1 b) (set-member? line2 b) (set-member? line3 b))) (error "enter a final location which exisits"))
(else "plan your journey"))))
here is my defined sets
(define line1 (set "a" "b" "c" "d" "e"))
(define line2 (set "f" "g" "c" "h" "i"))
(define line3 (set "k" "i" "l" "m" "e"))