Writing A Function Using Helper Functions

后端 未结 1 729
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 00:28

I\'m trying to write a function in Scheme that takes two strings as input and returns a list of all optimal pairs of strings. In order to do this, I know that I need to make use

1条回答
  •  生来不讨喜
    2021-01-24 01:09

    I think you have almost everything you need except for a function that can sort a list using a predicate function.

    If your Scheme interpreter does not provide a sorting function, you can use one found at Wikibooks . You'll have to adapt it to take a predicate function instead of using <= as the default predicate function.

    Your predicate function can be:

    (define (compare-by-alignment lhs rhs)
       (<= (alignment-score-tail lhs) (alignment-score-tail rhs)))
    

    You can call merge-sort using your list and predicate function as:

    (merge-sort lst compare-by-alignment)
    

    0 讨论(0)
提交回复
热议问题