In my programming languages course we are reviewing type inference, i didnt get very well how to make this task. I all ready search at the bibliography of my course (PLAI by Shriram krishnamurthi) which actually sucks big cock since he jump lots of steps in the few examples he expose. Does anybody know how to make the type inference of the following function?:

(define(for-each f lst)
(if (not null? lst
     (begin (f car lst for-each f 
                         (cdr lst)))))
  • $\begingroup$ Start with something simple, such as: what is the type of the function (define (f x) (+ x 3)). How do you know? What is the type of the function (define (comp f g) (lambda (x) (f (g x)))). How do you know? $\endgroup$ May 26 '14 at 16:53
  • $\begingroup$ probably it´s number since it´s a function application. When it´s an application it always return a number. Right? $\endgroup$ May 27 '14 at 4:25
  • $\begingroup$ Hmmm, find someone to talk to live if you can. That would be my best suggestion. A site like this is better for clarifying minor points about something that you broadly understand. $\endgroup$ May 27 '14 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.