extracreditLAB9 - which means it would have an infinite...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
* Extra Credit 1 (30%) Execute the short program below. What does it do? Explain as many of the different commands involved as you can discern. You may use the ? < command > option to access the Mathematica Book. * Print [ ToString [#0] [] ] & [] - The function Print [ToString[#0] [] ] has zero arguments, and #0 represents the function itself, so the argument of Print [ToString [#0] [] ], ToString [#0] [] is printed. The result of this evaluation is null because it is a Print statement. ToString comes into play in two ways, first since the quotes are not printed in Standard Form, a String looks the same as the corresponding symbol. Secondly, without the ToString, the result of the evaluation of the pure function Print [#0 [] ] would be Print [#0[] ], which would be evaluated and so on,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: which means it would have an infinite recursion. * Extra Credit 2 90 % : Can you code a program in the LC-3 machine language, that performs the same task? * .ORIG X3000; start at location X3000 LD R1, NUMBER; load the value into R1 LOOP; AND R1, R1, #-1; take the twos complement, first multiply by negative one ADD R1, R1, #1; take the twos complement, second by add one Brn, LOOP; If value is negative, proceed, otherwise LOOP HALT; halt the system .END; end of program This simulates a program that will take the twos complement, and since the twos complement will never be negative, an applied loop will make this process never ending and therefore self-replicating....
View Full Document

Page1 / 2

extracreditLAB9 - which means it would have an infinite...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online