Lazy (build-infinite-list)

5 views
Skip to first unread message

Scott Heidbrink

unread,
Dec 4, 2013, 5:06:07 PM12/4/13
to byu-cs-330...@googlegroups.com
(build-infinite-list f) is an infinite of the same function right? so calling (list-ref (build-infinite-list f) i) would return f at the i position. how would you make that then apply it to i since it needs to actually return (f i), without saying ((list-ref (build-infinite-list f) i) i)

Jay McCarthy

unread,
Dec 4, 2013, 5:10:19 PM12/4/13
to Scott Heidbrink, BYU CS 330 Fall 2013
On Wed, Dec 4, 2013 at 3:06 PM, Scott Heidbrink
<scott.h...@gmail.com> wrote:
> (build-infinite-list f) is an infinite of the same function right? so
> calling (list-ref (build-infinite-list f) i) would return f at the i
> position.

That is wrong because the assignment clearly says "(list-ref
(build-infinite-list f) i) returns (f i)" which contradicts what you
say.

> how would you make that then apply it to i since it needs to
> actually return (f i), without saying ((list-ref (build-infinite-list f) i)
> i)

That's the whole point of this function... you need to write it to do that.

Jay

>
> --
> You received this message because you are subscribed to the Google Groups
> "byu-cs-330-fall-2013" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to byu-cs-330-fall-...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93
Reply all
Reply to author
Forward
0 new messages