R – How to perform arithmetic calculations on symbols in Scheme/Lisp

lisp, racket, scheme, type-conversion

I need to perform calculations with a symbol. I need to convert the time which is of hh:mm form to the minutes passed.

;; (get-minutes symbol)->number;; convert the time in hh:mm to minutes;; (get-minutes 6:19)-> 6* 60 + 19(define (get-minutes time)  (let* ((a-time (string->list (symbol->string time)))         (hour (first a-time))         (minutes (third a-time)))     (+ (* hour 60) minutes)))

This is an incorrect code, I get a character after all that conversion and cannot perform a correct calculation.

Do you guys have any suggestions? I cant change the input type.
Context: The input is a flight schedule so I cannot alter the data structure.

;; ———————————————————————-

Edit:
Figured out an ugly solution. Please suggest something better.

(define (get-minutes time)  (let* ((a-time (symbol->string time))         (hour (string->number (substring a-time 0 1)))         (minutes (string->number (substring a-time 2 4))))     (+ (* hour 60) minutes)))

Best Solution

You can find a definition for string-split here. It will enable you to split a string at delimiters of your choice. Then you can define get-minutes like this:

(define (get-minutes time)  (let* ((fields (string-split (symbol->string time) '(#\:)))         (hour (string->number (first fields)))         (minutes (string->number (second fields))))    (+ (* hour 60) minutes)))