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, 曹朝 <cz1...@gmail.com> 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 racket-users+unsubscr...@googlegroups.com 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> 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 
> <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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/19F2258A-7D7B-4A5D-B93B-542CBE374D69%40felleisen.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to