Skip to content

fixes #836 #1023

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

Merged
merged 3 commits into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions xml/chapter3/section3/subsection4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -570,21 +570,6 @@ function logical_and(s1, s2) {
}
</JAVASCRIPT>
</SNIPPET>
<SNIPPET HIDE="yes">
<NAME>logical_or</NAME>
<JAVASCRIPT>
function logical_or(s1, s2) {
return s1 === 0 &amp;&amp; s2 === 0
? 0
: s1 === 0 || s1 === 1
? s2 === 0 || s2 === 1
? 1
: error(s2, "invalid signal")
: error(s1, "invalid signal");
}
</JAVASCRIPT>
</SNIPPET>

<PDF_ONLY>
<!-- Figure moved here from earlier for SICP JS pagination -->
<!-- Figure code is copy of code earlier in this file in a WEB_ONLY -->
Expand Down Expand Up @@ -673,12 +658,32 @@ function and_gate(a1, a2, output) {
<JAVASCRIPT><JAVASCRIPTINLINE>and_gate</JAVASCRIPTINLINE>.
</JAVASCRIPT>
</SPLITINLINE>
<SNIPPET HIDE="yes">
<NAME>or_gate</NAME>
<REQUIRES>get_signal</REQUIRES>
<REQUIRES>after_delay</REQUIRES>
<REQUIRES>logical_or</REQUIRES>
<JAVASCRIPT>
<LABEL NAME="ex:3_28"/>
<SOLUTION>
<SNIPPET>
<NAME>logical_or</NAME>
<JAVASCRIPT>
// contributed by GitHub user clean99

function logical_or(s1, s2) {
return s1 === 0 &amp;&amp; s2 === 0
? 0
: s1 === 0 || s1 === 1
? s2 === 0 || s2 === 1
? 1
: error(s2, "invalid signal")
: error(s1, "invalid signal");
}
</JAVASCRIPT>
</SNIPPET>
<SNIPPET>
<NAME>or_gate</NAME>
<REQUIRES>get_signal</REQUIRES>
<REQUIRES>after_delay</REQUIRES>
<REQUIRES>logical_or</REQUIRES>
<JAVASCRIPT>
// contributed by GitHub user clean99

function or_gate(a1, a2, output) {
function or_action_function() {
const new_value = logical_or(get_signal(a1),
Expand All @@ -690,9 +695,9 @@ function or_gate(a1, a2, output) {
add_action(a2, or_action_function);
return "ok";
}
</JAVASCRIPT>
</SNIPPET>
<LABEL NAME="ex:3_28"/>
</JAVASCRIPT>
</SNIPPET>
</SOLUTION>
</EXERCISE>

<EXERCISE>
Expand Down
Loading