COSC3308 TEST-2(B)					11/26/2002

	Note that due to HTML syntax conflicts, "<" is replaced by
	"!" where needed.


	NAME________________________________________
		
	PART-A.	Multiple Choice questions.			(72 points)
Select the BEST answer by writing down a BIG letter A,B,C,D,E, or F right  by the 
question number.

	1. 	ABC   = "SUPER"
		SUPER = "NICE"
		NICE  = "GOOD"
		Good  = 'GOOD'
	OUTPUT  =  $$$SUPER

		Which string will be output?
		a.	"NICE"			b.	"GOOD"
		c.	Neither

	2.	&fullscan  =  0		;* We have the default "QuickScan"
		&Anchor    =  0
Pat  = 'a'  |  'b' *Pat 
		'bbba'  Pat  $  Output  Fail

		Which will be included in the outputs?
		a.	bbb				b.	bbba
		c.	Both.				d.	Neither

	3.	&Fullscan = 1;	&Anchor = 0
		Pat  =  *Pat  'a'  |  'b'
		'baaa'  Pat  $  Output  Fail

		Which will be included in the outputs before any possible error message?
		a.	baaa				b.	baa
		c.	Both.				d.	Neither.

	4.	&Anchor = 0
		"((A+B))"  Bal  $  Output  Fail
	
		Which will be included in the outputs?
		a.	(A+B)				b.	A+B			c.	A+
		d.	All above.			e.	Two above.		f.	None
	
	5.	Which can match the null string?
		a.	Span()			b.	Break()		c.	BAL
		d.	All above.			c.	Two above.

	6.	Which matches nothing but the null string?
		a.	Tab(N) and RTab(N)
		b.	Pos(N) and Rpos(N)
		c.	fail				d.	Two above.		e.	None.

	7.	N = LE(N,Max)     N + 1
		N   LE(N,Max)  =  N + 1
		a.	Above are the same if the predicate succeeds.
		b.	Above are the same if the predicate fails.
		c.	Both.			d.	Neither.

	8.	S1 =  "AB"  "CD"
		S2 =  "ABCD"
		Ident(S1,S2)

		a.	Above succeeds.		b. 	Above fails.	
		c.	Cannot tell

	9.	X =  Array(4,6)
		X!1>  =  "GOOD"
		X!2>  =  12345
		Output = X!1>  X!2>  X!3>

		Above will yield
		a.	an output string of: "GOOD123456"
		b.	a syntax error due to inconsistent data types.
		c.	Neither.			d.	Cannot tell.

	10.	differ(X,Y)			:F(NoGood)
		differ(Y,Z)			:S(Good)F(NoGood)
	    
The above two lines are equivalent to:
		a.		differ(X,Y)  differ(Y,Z)   		:S(Good)F(NoGood)
		b.		Ident(X,Y)    Ident(Y,Z)		:S(NoGood)F(Good)
		c.		Both.				d.	Neither

	Next two questions are about the following program segment:
			
&Anchor = 0;	&FullScan = 1
  			Define("P(X,Y,Z)")
			Pat = len(1) $ A ARB len(1) $ B ARB len(1) $ C *P(A,B,C) Fail
			"12345"  Pat				:(End)
		*     Function starts here
		P	Output = X  " "  Y  " "  Z		:(Return)
		End

	11.	The first three output lines will be
		a.		1 2 3			b.	1 2 3			c.	Neither.
				1 2 4				2 3 4
				1 2 5				3 4 5

	12.	Suppose that:	&Anchor   =  1;	&FullScan =  0

		In this case, the first two output lines would be
		a.		1 2 3			b.	1 2 3			c.	Neither.
				1 2 4				2 3 4

	13.	The Static Scope is more natural when
		a.	subprograms may not nest others.
		b.	local variables are likely to be visible to subprograms to be
			called.
		c.	Both.			d.	Neither.

	14.	Which is true of Referencing Environment?
		a.	Scope rule affects both its local part and non-local part.
		b.	It generally changes each time a subprogram is called but not
 			when subprograms do return.
		c.	Both.			d.	Neither.

	15. 	Pass-By-Name has the same effect as Pass-By-Reference when the actual
argument is
		a. a constant like 16
		b. a scalar variable like ABC
		c. an array element like X[k]
		d. All above.		e.	Two above.			f.	None

	16.	Which can induce aliasing?
		a.	Pass-by-Name		b.	Pass-by-Reference
		c.	Pass-by-Value-Result	d.	Two  above.		e.	None.

	17.	Deciding the Referencing Environment of Parameter Subprograms (those
		subprograms that are passed as actual arguments) becomes an issue when
		a.	Static scope is used
		b.	Dynamic scope is used.
		c.	Both.			d.	Neither.

	18.	An advantage of Pass-by-Name includes
		a.	subprogram flexibility.
		b.	implementing Out-Mode semantic only.
		c.	Both.			d.	Neither.



	PART-B. Other Problems.				(28 points)

	Choose three problems in this PART-B.

	A. 	In no more than 8 lines, explain some Orthogonality enhancements of
		Snobol4. 

	B. 			define('three(a,b,c)')

	   	Complete this function that finds and prints all combinations of
	   	three numbers out of 9 numbers: 1,2,3,4,5,6,7,8,9.


	C. 	In no more than 8 lines, describe some advantages and disadvantages 
 		of Pass-By-Name parameter passing.


	D.	Complete the following function definition
 				Define("Strip(X)")
		This function
		1. strips all blanks off and
		2. removes any number of extra outermost pairs of parentheses.
		For example,   Strip("    ((A+B*((C  +  D  * E ))F))   ")   will become
                                        A+B*((C+D*E))F