Scheme/Lisp Programming Help | INFJ Forum

Scheme/Lisp Programming Help

Discussion in 'Computer Science' started by foggymask, Feb 21, 2012.

Share This Page

More threads by foggymask
  1. foggymask

    Joined:
    Feb 21, 2012
    Threads:
    1
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    MBTI:
    ISTP
    Enneagram:
    9 Omni
    Hey everyone, I am trying to write a lambda function that will return with another function when you plug in certain numbers. I could really use some help understanding it. Here is the actual problem:

    Often times in programming it will make sense to generalize a problem. One such way to create
    a function to calculate a solution. You have learned how to define functions that return a value,
    but in Scheme you can also define functions that return new functions as their return value.
    Take the quadratic functions f(x) = x^2 + 2x + 3 and f(x) = 3x^2 + x + 1 for example. We don't
    want to define a new function by hand for every quadratic polynomial we write. We can
    generalize quadratic functions to f(x) = ax^2 + bx + c.
    Your job is to write a function that takes the coefficients a, b, and c as arguments and returns a
    function (using lambda) that can be evaluated at any x.
    (define (gen-poly a b c))
    (define test-poly (gen-poly 1 1 1))
    (test-poly 1) ; returns 3
     
  2. Deathjam

    Deathjam ooooh
    Staff Member Tech Admin

    Joined:
    Aug 28, 2008
    Threads:
    410
    Messages:
    4,552
    Featured Threads:
    6
    Likes Received:
    1,647
    Trophy Points:
    856
    Gender:
    Male
    Location:
    Yorkshire, UK
    MBTI:
    ENTP
    Is this homework?


    Sent from my HTC Desire HD A9191 using Tapatalk
     
  3. Nixie

    Nixie Resurrected

    Joined:
    Aug 23, 2010
    Threads:
    84
    Messages:
    9,521
    Featured Threads:
    3
    Likes Received:
    3,595
    Trophy Points:
    976
    Gender:
    Female
    Location:
    Oregon
    MBTI:
    ENTP
    What does it matter? It is all gobbodly gook anyway.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Deathjam

    Deathjam ooooh
    Staff Member Tech Admin

    Joined:
    Aug 28, 2008
    Threads:
    410
    Messages:
    4,552
    Featured Threads:
    6
    Likes Received:
    1,647
    Trophy Points:
    856
    Gender:
    Male
    Location:
    Yorkshire, UK
    MBTI:
    ENTP
    it doesn't really matter if its gobbodly gook or not, the fact that its a straight copy of page 3 of this document, to me looks like he/she is basically asking us how to do their homework for them
     
    Nixie likes this.
  5. technics

    On Holiday

    Joined:
    May 13, 2011
    Threads:
    96
    Messages:
    999
    Featured Threads:
    1
    Likes Received:
    173
    Trophy Points:
    0
    MBTI:
    Yes
    Damn, lazy ISTPs...
     
Loading...

Share This Page