From: Gopi
Subject: Functional Programming - Need help ASAP..
Date: 
Message-ID: <1102638948.6c6db77e9c98ad365228e17cb6e58967@tng>
Magic Code Test

Please answer the following questions about software engineering and
coding in general
Please answer the following questions about Magic Lite using the code
instructions found Here

The following lines of code build a file 0 with each line of code
inheriting the state left after the previous line of code has executed.
What are the results of the following lines of code: (i.e. what is left
in the register and what does file 0 look like after executing each
line of code)

Definitions:
Functions are defined as two character upper-case alphas preceded by an
at sign (@). Functions will perform operations on a data register and
leave their result in that register. If a function does not return a
value, the value already in the register remains there. 
OT 
create temporary file 0 
R0 
read record from file 0 (returns a value - i.e. puts the record in the
register) 
W0 
write contents of the register to the current record in file 0,
overwriting the value that had been in that record 
N0 
move to next record in file 0 
P0 
move to previous record in file 0 
F0 
move to first record (head) of file 0 
L0 
move to last record (tail) of file 0 
CT 
close temporary file 0 

All operations on file 0 are also valid on files 1-9. Records can
contain atoms (text or numeric strings) or lists. Lists are bounded by
braces (e.g. {}) and elements in those lists are separated by commas.
An element of a list can be an atom or another list {0,1,2,3} is a list
of the atoms 0,1, 2 and 3. Non-numeric text atoms need quotation marks
(") around them. 
The declaration of an atom or list replaces the existing value in the
register with that atom or list. 

| is the piece operator, acts on the register to extract elements from
a list. The elements are numbered beginning with 0
{3,7,1}|1 returns 7

{3,7,··@W0|1 would write {3,7,1} to file 0 and then execute |1 to
return 7 

A list may be the argument to the piece operator. Each position listed
is returned in a list
{"ABC","DEF","G",7}|{1,3} returns {"DEF",7} 

+ is the addition operator
1+3 leaves 4 in the register 

@+ is the list addition operator
{3,··@+ returns 8 


................Please answer the following codes............

Question 4

@OT,·@··@N0,{2,4,6,··@··@N0,·@··@··@··@R0

Register 	 

Record 	 


Question 5

@R0+(@··@R0|1)+(@··@R0)

Register 	 

Record 	 


Question 6

@··@··@····@··@W0

Register 	 

Record 	 


Question 7

@··@R0+(@··@R0)

Register 	 

Record 	 


Question 8

@··@R0|{1,··@··@··@W0|0

Register 	 

Record 	 


Question 9

@··@·@W0

Register 	 

Record 	 


Question 10

@··@··@····@··@···@··@CT

Register 	 

Record 	 


Question 11

Write the code to produce the following file:

{"A","B"}
"C"
{1,2,3}
{4,5,6}


Question 12

What is the difference between a Record and the Register?



--
Gopi
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------