Rewrite the list insertion method of Example C 16.40 in F# instead of C#. Compile to CIL
Question:
Rewrite the list insertion method of Example C 16.40 in F# instead of C#. Compile to CIL and compare to the right side of Figure C 16.7. Discuss any differences you find.
Figure 16.7
Transcribed Image Text:
. method private hidebysig public void insert (int v) { instance default void insert (int32 v) cil managed { // Method begins at RVA Ox210c // Code size 108 (Ox6c) // RVA == relative // virtual address .maxstack 3 .locals init ( class LLset/node // n V_0, V_1) class LLset/node // t node n = head; IL 0000: ldarg.0 IL_0001: ldfld class LLset/node LLset: :head IL_0006: stloc.0 // jump to header of rotated loop // n -- beginning of loop body IL_0007: br IL_0013 IL 000c: ldloc.0 IL 000d: 1dfld class LLset/node LLset/node::next IL 0012: stloc.0 -3- // n = n.next // n -- beginning of loop test while (n.next != null IL_0013: ldloc.0 &k n.next.val < v) { IL_0014: ldfld class LLset/node LLset/node: :next IL_0019: brfalse IL_002f // exit loop if n null // n IL_001e: ldloc.0 IL 001f: ldfld class LLset/node LLset/node::next IL 0024: 1dfld int32 LLset/node::val n = n.next; } // v // continue loop IL_0029: 1darg.1 IL_002a: blt IL 000c // n if (n.next == null || n.next.val > v) { IL_002f : ldloc.0 IL 0030: 1dfld class LLset/node LLset/node:: IL_0035: brfalse IL 004b IL_003a: ldloc.0 IL 003b: 1dfld class LLset/node LLset/node::nex IL 0040: 1dfld int32 LLset/node:: val next // n t // v IL_0045: ldarg.1 IL_0046: ble IL 006b IL_004b: newobj instance void class LLset/node::'.ctor' () IL 0050: stloc.1 IL_0051: ldloc.1 IL 0052: 1darg.1 IL 0053: stfld int32 LLset/node::val node t = new node (); // t // t // v t.val = v; // t // n IL_0058: ldloc.1 IL 0059: ldloc.0 IL_005a: ldfld class LLset/node LLset/node::next IL_005f: stfld class LLset/node LLset/node::next t.next = n.next; // n // t n.next = t; IL 0064: ldloc.0 IL_0065: 1dloc.1 IL 0066: stfld class LLset/node LLset/node::next } // else v already in set IL_006b: ret } // end of method LLset::insert
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 80% (5 reviews)
ANSWER let insert v int let rec l...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Rewrite the example shown in Figure 8-4 using Java.
-
The right side of Figure shows a system that simulates the manufacture of computer chips. The equations in the simulation system are based on statistical probabilities of failures in the...
-
In Figure Q14.31, an air stream moves from right to left through a tube that is constricted at the middle. Three Ping-Pong balls are levitated in equilibrium above the vertical columns through which...
-
Following the 2017 General Election and change of government, the Labour-led coalition government established a Tax Working Group (TWG) to consider the overall structure, balance and fairness of the...
-
An insulated piston - cylinder device initially contains 20 L of air at 140 kPa and 27C. Air is now heated for 10 min by a 100-W resistance heater placed inside the cylinder. The pressure of air is...
-
Solve the equation: (x + 10) (3x-1) = - 7x - 118 x =
-
The efficiency of an ideal machine is 50%. True or False
-
A company uses the following acceptance-sampling procedure. A sample equal to 10% of the lot is taken. If 2% or less of the items in the sample are defective, the lot is accepted; otherwise, it is...
-
a- What is the output of implementing the class Entity2 in the following code class Entity1 { public Entity1() { } System.out.println("Entity1's no-arg constructor is invoked"); } class Entity3...
-
Jimmy owns a garden in which he has planted N trees in a row. After a few years, the trees have grown up and now they have different heights. Jimmy pays much attention to the aesthetics of his...
-
Building on the previous exercise, rewrite your list insertion routine (both C# and F# versions) to be generic in the type of the list elements. Compare the generic and non generic versions of the...
-
Using your local implementations of Java and C#, compile the code of Figures 16.2 and C 16.7 all the way to machine language. Disassemble and compare the results. Can all the differences be...
-
How can the government offset a lack of private demand? How does this help prevent a recession?
-
A U.S. life insurance company that buys British government bonds faces foreign-exchange risk. Specify the nature of that risk in terms of the company's expected return in U.S. dollars.
-
What is the primary purpose of a credit derivative?
-
What are the four major concerns that have been identified with new credit risk transfer vehicles?
-
In a credit default swap, what is meant by a. a reference entity? b. a reference obligation?
-
Why does increased volatility in financial markets with respect to the price of financial assets, interest rates, and exchange rates foster financial innovation?
-
A concave mirror (R = 56.0 cm) is used to project a transparent slide onto a wall. The slide is located at a distance of 31.0 cm from the mirror, and a small flashlight shines light through the slide...
-
A woman at a point A on the shore of a circular lake with radius 2 mi wants to arrive at the point C diametrically opposite on the other side of the lake in the shortest possible A time. She can walk...
-
Transmission of information in any network involves end-to-end addressing and sometimes local addressing (such as VCI). Table 8.2 shows the types of networks and the addressing mechanism used in each...
-
A path in a digital circuit-switched network has a data rate of 1 Mbps. The exchange of 1000 bits is required for the setup and teardown phases. The distance between two parties is 5000 km. Answer...
-
Describe the need for switching and define a switch.
-
Discuss with examples about financial innovation& how it develops banking industry?
-
Elaborate with real world examples about different financial markets that contributed towards growth of financial sector?
-
The following statement of financial position is for the partnership of Able, Brown, and Crown at November 1, 2018. Assets Liabilities Cash $ 20,000 Accounts payable $ 50,000 Other assets 180,000...
Study smarter with the SolutionInn App