sorawee
2019-12-31 10:17:45

One thing I used to do is to use for with (in-naturals), but that’s probably not the best way to do things since it obscures what you really want to do.

What’s wrong with the while loop you linked above? What problems do you get with typechecking?


p.kushwaha97
2019-12-31 10:43:02

sorawee: I was getting an error saying something along the lines of “please provide more type annotations, unable to typecheck” and the code it quoted was the entire while loop. I tried adding “Any” annotation for the body and “Boolean” for the condition but I had the same error.

I just changed my code to named lets. I didn’t know about this language feature, it actually made some mutations unnecessary so I guess it’s a better solution.


soegaard2
2019-12-31 15:28:15

Use either for or a so-called ¨named let”.


john.champaign
2019-12-31 21:01:50

@sorawee that’s exactly what I was looking for. thanks so much!


plragde
2020-1-1 00:43:13

I’m not sure SICP can properly inform an algorithms class. I think it’s important to use structures with named fields instead of lists for everything. If your algorithms class includes data structures, you might get some ideas from my course: https://cs.uwaterloo.ca/~plragde/flaneries/FDS/