0% found this document useful (0 votes)
32 views

Assignment 5 Procedures and Decision

The document discusses Scheme procedures and decision expressions. It provides two Scheme expressions to evaluate and construct parse trees for, and defines two procedures - absvalue that returns the absolute value of a number, and bigger-magnitude that returns the number with the greater magnitude from two inputs.

Uploaded by

Roiz Hipolito
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Assignment 5 Procedures and Decision

The document discusses Scheme procedures and decision expressions. It provides two Scheme expressions to evaluate and construct parse trees for, and defines two procedures - absvalue that returns the absolute value of a number, and bigger-magnitude that returns the number with the greater magnitude from two inputs.

Uploaded by

Roiz Hipolito
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 5

SCHEME: PROCEDURES AND DECISION

A. Evaluate the following scheme expression below and construct the parse tree accordingly:

a. ( lambda (a) ((lambda (b) (+ a b)) 3))


b. ((lambda (a) ((lambda(b) (+ a b) )3 )) 4 )

B. Find the scheme procedure and name definition for the following scheme decision expression:

a. absvalue, that takes a number as input and produces the absolute value of that number
as its output. For example, (absvalue 3) should evaluate to 3 and (absvalue −150)
should evaluate to 150.

b. bigger-magnitude, that takes two inputs, and outputs the value of the input with the
greater magnitude (that is, absolute distance from zero). For example, (bigger-
magnitude 5 −7) should evaluate to −7, and (bigger-magnitude 9 −3) should evaluate to
9.

You might also like