ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

Ruby and IO

by | Nov 30, 2023 | questions

Do define a number of functions. Do use classes, somehow, either
creating new ones of your own design or adding to existing classes.
If want an idea: try a simple LISP subset, using Ruby’s lists as the
underlying data structure.
Lists are class Array, so you could do
class Array
def car()
self[0]
end
# etc
end
which will allow you to write “[2, 4, 5].car”
Ruby:
Implement car, cdr, cons (cons is probably just a stand-alone function).
How about some of the utility functions: length; assoc (with an
argument like [[:top, 24], [:bottom, 12]] )

2. This simple Hanoi has a problem: it tells you all the moves, but
not what’s on each pole as we move through the game. Here’s an example
from a solution which I did in Java last year. Can you do as well in
Io? Shouldn’t be too hard, given that it has “push” and “pop” builtins.
% java Hanoi 3
At beginning: A[3, 2, 1]
B[] C[]
Task: move 3 from A[3, 2, 1] to B[]
first clear 2 from A[3, 2, 1] to C[]
Task: move 2 from A[3, 2, 1] to C[]
first clear 1 from A[3, 2, 1] to B[]
Move: #1 from A to B A[3, 2]
B[1] C[]
done clearing 1 from A[3, 2] to B[1]
Move: #2 from A to C A[3] B[1] C[2]
unclear 1 from B[1] to C[2]
Move: #1 from B to C A[3] B[]
C[2, 1]
done moving 2 from A[3] to C[2, 1]
done clearing 2 from A[3] to C[2, 1]
Move: #3 from A to B A[] B[3]
C[2, 1]
unclear 2 from C[2, 1] to B[3]
Task: move 2 from C[2, 1] to B[3]
first clear 1 from C[2, 1] to A[]
Move: #1 from C to A A[1] B[3] C[2]
done clearing 1 from C[2] to A[1]
Move: #2 from C to B A[1] B[3,
2] C[]
unclear 1 from A[1] to B[3, 2]
Move: #1 from A to B A[] B[3, 2,
1] C[]
done moving 2 from C[] to B[3, 2, 1]
done moving 3 from A[] to B[3, 2, 1]
All finished: A[] B[3, 2,
1] C[]
done, 7 moves for 3 disks

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!