I'm looking at this from https://github.com/dparpyani/99-Lisp-Problems-in-Racket:
#lang racket (require typed/racket) ;; Question: ;; Find the last box of a list. ;; Example: ;; (my-last '(a b c d)) ;; => '(d) ;; Consumes a list and returns the last element in it. (define (my-last lst) (cond [(or (empty? lst) (empty? (rest lst))) lst] [else (my-last (rest lst))])) ;; Tests (assert (equal? (my-last `(a b c d)) `(d))) (assert (equal? (my-last `(1 2 3 4)) `(4))) (assert (equal? (my-last `((a b) (c d))) `((c d)))) ...which seems to behave fine when loaded from the command line, i.e., #> racket Q01.rkt #t #t #t However, when loaded from with a Racket REPL > (load "Q01.rkt") > (my-last '(1 2 3)) ; readline-input:14:1: Type Checker: missing type for top-level identifier; ; either undefined or missing a type annotation ; identifier: my-last ; in: my-last ; [,bt for context] Likewise, simply entering everything in the REPL also fails: > (require typed/racket) > (define (my-last lst) (cond [(or (empty? lst) (empty? (rest lst))) lst] [else (my-last (rest lst))])) ; readline-input:18:30: Type Checker: Polymorphic function `rest' could not be ; applied to arguments: ; Domains: (Listof a) ; (Pairof a (Listof b)) ; Arguments: Any ; in: (rest lst) ; [,bt for context] Why the different behaviors? All I'm trying to do is use assert. But then how would I change this code to be typed Racket? -- 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. For more options, visit https://groups.google.com/d/optout.