-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sounds: long-established demo no longer working properly #212
Comments
i think the issue might be in js-slang repo under the current implementation of
|
Hmm this one's on me. I'll fix this and incorporate some tests with my latest js-slang PR |
OK. Note that the accumulate function in Source Academy uses continuation passing style, to make sure it doesn't lead to JS-runtime-stack overflow:
A note on the list library: We have two versions: I think having two versions is acceptable because they seem to serve different purposes. Maybe the version (1) isn't covered by regression testing, which means the bug slipped through. [BTW, there is a third version: |
Would the following implementation work? export function accumulate<T, U>(op: (each: T, result: U) => any, initial: U, sequence: List): U {
// Use CPS to prevent stack overflow
function $accumulate(f: typeof op, xs: typeof sequence, cont: (each: U) => U): U {
return is_null(xs) ? cont(initial) : $accumulate(f, tail(xs), x => cont(f(head(xs), x)));
}
return $accumulate(op, sequence, x => x);
} With this implementation the sounds demo works as expected |
yes, that's correct. You can include this in a PR. |
Prof @martin-henz, we need to bump js-slang to fix this fully. Otherwise, this issue is closed via source-academy/js-slang#1463. |
Expected Behavior
Bohemian rapsody cover should be heard when playing
https://share.sourceacademy.org/g9n0m
using Source §2 or Source §2 native
Current Behavior
Something else is heard that has some of the harmonies of Bohemian rapsody, but sounds very different.
Failure Information (for bugs)
Steps to Reproduce
Run
https://share.sourceacademy.org/g9n0m
Context
MacBook Pro, x86, MacOS Monterey
The text was updated successfully, but these errors were encountered: