Discussion:
Return types for Scheme functions
(too old to reply)
cd cs134/A03
2011-03-24 18:41:27 UTC
Permalink
For the two functions

(define (bst-insert root key) ... )
(define (bst-search root key) ... )

I'm assuming the return types are void and boolean respectively?
Bo Hu
2011-03-24 19:00:21 UTC
Permalink
Post by cd cs134/A03
For the two functions
(define (bst-insert root key) ... )
(define (bst-search root key) ... )
I'm assuming the return types are void and boolean respectively?
I think you can return whatever you want.
Justin Reardon
2011-03-24 20:26:38 UTC
Permalink
Post by Bo Hu
Post by cd cs134/A03
For the two functions
(define (bst-insert root key) ... )
(define (bst-search root key) ... )
I'm assuming the return types are void and boolean respectively?
I think you can return whatever you want.
If we can return anything, then how are the marmoset tests supposed to
work? Surely bst-search at least must return certain values? If bst-insert
does not require particular return values then presumably we cannot rely on
being able to build the tree in a functional manner, but we still haven't
been given an answer to that either.
--
Thanks, Justin
Joseph
2011-03-24 20:56:36 UTC
Permalink
Post by Justin Reardon
Post by Bo Hu
Post by cd cs134/A03
For the two functions
(define (bst-insert root key) ... )
(define (bst-search root key) ... )
I'm assuming the return types are void and boolean respectively?
I think you can return whatever you want.
If we can return anything, then how are the marmoset tests supposed to
work? Surely bst-search at least must return certain values? If bst-insert
does not require particular return values then presumably we cannot rely on
being able to build the tree in a functional manner, but we still haven't
been given an answer to that either.
I think providing us with some sample code from the scheme and ML
automated tests might help.

For example FingerTree in ML:
val testTree =
bst_insert(
bst_insert(
bst_insert(
bst_insert(
bst_insert(
bst_insert( Leaf, 5 ), 2 ), 8), 3), 4), 1 )
bst_search( testTree, 4 );
should have the following on standard out:
1234

For example FingerTree in Scheme:
( define testTree ( bst-insert( bst-insert( bst-insert( bst-insert(
bst-insert ( bst-insert null 5) 2) 8) 3) 4) 1) )

should have the following on standard out:
1234
( bst-search tree newValue )


Or maybe using a similar interface to testing the C program would be
easier to test. That way you won't have to worry about our interface.
IE for each test you would call:
ML: build_search( size, array, num)
Scheme: (build_search size array num)
Similar to C: void build_search(int _size, int *_array, int _num) ;

Cheers,
Joseph
Bo Hu
2011-03-24 22:59:07 UTC
Permalink
I upload the instruction for submitting, you can check whether that is
helpful.
Justin Reardon
2011-03-24 23:23:23 UTC
Permalink
I upload the instruction for submitting, you can check whether that is helpful.
Much better, thanks! So, essentially, the output for the Scheme and ML
versions should be as described in the posts you made about the C
version, yes?
Bo Hu
2011-03-24 23:29:36 UTC
Permalink
Post by Justin Reardon
I upload the instruction for submitting, you can check whether that is helpful.
Much better, thanks! So, essentially, the output for the Scheme and ML
versions should be as described in the posts you made about the C
version, yes?
Yes, they are all the same.

Loading...