I'm quite new to functional programming, especially Scheme as used below. I'm trying to make the following function that is recursive, tail recursive. Basically, what the function does, is scores the alignment of two strings. When given two strings as input, it compares each "column" of characters and accumulates a score for that alignment, based on a scoring scheme that is implemented in a function called scorer that is called by the function in the code below.
I sort of have an idea of using a helper function to accumulate the score, but I'm not too sure how to do that, hence how would I go about making the function below tail-recursive?
(define (alignment-score string_one string_two) (if (and (not (= (string-length string_one) 0)) (not (=(string-length string_two) 0))) (+ (scorer (string-ref string_one 0) (string-ref string_two 0)) (alignment-score-not-tail (substring string_one 1 (string-length string_one)) (substring string_two 1 (string-length string_two)) ) ) 0) )