although these test cases are easily verified with a calculator, here is a test script for completeness.

create test script test8.sh with the following

allow it to be executed with the command

run it with

My results:

Also, did anyone else find implementing the "halve" function surprisingly tricky?

I got something that's O( (lg n)^2 ).

create test script test8.sh with the following

Code:

`#!/bin/bash`

echo "(21 42)" > results8.txt

echo "(21 42)" > task8.args

scam -r task8.scm task8.args >> results8.txt

echo "(1 2)" >> results8.txt

echo "(1 2)" > task8.args

scam -r task8.scm task8.args >> results8.txt

echo "(2 4)" >> results8.txt

echo "(2 4)" > task8.args

scam -r task8.scm task8.args >> results8.txt

echo "(15 65)" >> results8.txt

echo "(15 65)" > task8.args

scam -r task8.scm task8.args >> results8.txt

echo "(124 642)" >> results8.txt

echo "(124 642)" > task8.args

scam -r task8.scm task8.args >> results8.txt

cat results8.txt

allow it to be executed with the command

Code:

`chmod u+x test8.sh`

run it with

Code:

`./test8.sh`

My results:

Code:

`(21 42)`

half of 21 is 10

half of 42 is 21

21 squared is 441

42 squared is 1764

882

(1 2)

half of 1 is 0

half of 2 is 1

1 squared is 1

2 squared is 4

2

(2 4)

half of 2 is 1

half of 4 is 2

2 squared is 4

4 squared is 16

8

(15 65)

half of 15 is 7

half of 65 is 32

15 squared is 225

65 squared is 4225

975

(124 642)

half of 124 is 62

half of 642 is 321

124 squared is 15376

642 squared is 412164

79608

Also, did anyone else find implementing the "halve" function surprisingly tricky?

I got something that's O( (lg n)^2 ).