Results 1 to 1 of 1

Thread: Church numerals

  1. #1
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Church numerals

    I'm looking for some help in understanding this question in sicp, 2.6:
    If zero is
    Java Code:
    (define zero(lambda(f)(lambda(x)x)))
    And add-1 is
    Java Code:
    (define(add-1 n)
      (lambda(f)(lambda(x)(f((n f)x)))))
    I'm having a hard time understanding these things.

    Zero takes an argument and returns a procedure which simple produces the identity of an argument, is this correct thinking? If so, how is this zero? Wouldn't it be dependent on the input argument?

    I'm wondering, is there a way to formulate this with less use of lambda? I'm trying to but I am having a hard time. I'm thinking if I see it without the lbda it may make more sense.

    I'm just looking for a bit of help in really understanding it.


    Edit: I read up on church numerals and believe I understand it more, basically zero isn't representing the numerical 0, instead an abstraction of the idea of zero. In this case it applies the passed in argument 0 times, correct?

    So add 1 will simply increase the amount of times the procedure will be applied to x, in the case of zero, add1 will change zero to one, or
    Java Code:
    (define one
      (lambda(f)
        (lambda(x)
          (f x))))
    Please tell me this is correct, I think I'm understanding it, it's a bit straining to realize what you are trying to calculate.

    Java Code:
    (define three
      (lambda(f)
        (lambda(x)
          (f(f(f x))))))
    (three inc 0) would be 3 right?
    
    (define(inc x)
      (+ x 1))
    Last edited by sunde887; 05-13-2011 at 08:19 AM.

Similar Threads

  1. Convert the number to Roman numerals
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 9
    Last Post: 11-29-2012, 10:44 PM
  2. Convert roman numerals
    By matzahboy in forum New To Java
    Replies: 4
    Last Post: 02-21-2010, 10:06 PM
  3. convert from roman numerals to integers and vice versa
    By number1cynic in forum New To Java
    Replies: 10
    Last Post: 01-18-2010, 11:54 PM
  4. Convert roman numerals to integers
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 11:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •