Alright, thank you very much. 在 2019年7月8日星期一 UTC+8上午3:50:18,Matthias Felleisen写道: > > > With some for/loops in TR you’re out of luck. The expansion are too > complex to type-check easily. > > > On Jul 7, 2019, at 10:24 AM, 曹朝 <[email protected] <javascript:>> wrote: > > This is a simple algorithm for compute the shortest edit distance, it can > work with `#lang racket/base`. > But in Typed Racket, I just got the error message: "insufficient type > information to typecheck". I don't know why this code can't pass the type > checker. > Someone can help? Thank you. > > #lang typed/racket/base > (require math/array) > > (: shortest-edit-distance (-> String String Integer)) > (define (shortest-edit-distance str0 str1) > (let* ([l0 : Integer (string-length str0)] > [l1 : Integer (string-length str1)] > [table : (Mutable-Array Integer) (array->mutable-array (make-array > (vector l0 l1) 0))]) > (for*/last : Integer ([i0 : Integer (in-range l0)] > [i1 : Integer (in-range l1)]) > (let* ([c0 : Char (string-ref str0 i0)] > [c1 : Char (string-ref str1 i1)] > [base : Integer (cond > [(and (= i0 0) (= i1 0)) 0] > [(= i0 0) (array-ref table (vector i0 (sub1 > i1)))] > [(= i1 0) (array-ref table (vector (sub1 i0) > i1))] > [else (min (array-ref table (vector i0 (sub1 > i1))) > (array-ref table (vector (sub1 i0) > i1)) > (array-ref table (vector (sub1 i0) > (sub1 i1))))])] > [answer : Integer (if (char=? c0 c1) base (add1 base))]) > > (array-set! table (vector i0 i1) answer) > answer)))) > > <截屏2019-07-0800.15.13.png> > > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/racket-users/1fa2f544-9f60-4e00-a451-b42b1e4f5b0f%40googlegroups.com > > <https://groups.google.com/d/msgid/racket-users/1fa2f544-9f60-4e00-a451-b42b1e4f5b0f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > <截屏2019-07-0800.15.13.png> > > >
-- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/b9998370-acae-47af-8672-4798fdaace20%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

