Re: Tasks
- Posted by "Hawke'" <mikedeland at NETZERO.NET> Aug 14, 2000
- 451 views
------=_NextPart_000_00BE_01C005A4.2D538E80 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable From: Asif Masood Baloch=20 I've done quite homework on EU programming and i want you friends to = help me evaluate myself. Send me small programming tasks so that i can = have feedback. It will be appreciated. here are a couple 'easy' tasks to challenge your coding skills... naturally, looking up the answer in a library would be 'cheating' ;) try to code them as best you can yourself :) some of them can be done in Euphoria with a single line of code within a function.... there may be (indeed!) more then one way to implement each of these challenges, and included many lines down in this email are some potential solutions for each of these tasks/challenges... 1: create a reverse() function that reverses the order of any sequence. eg: pass the function {1,2,3,4,5} and it returns {5,4,3,2,1} eg: pass the function "Hello" and it returns "elloH" 2: create a delete() function that removes any element of a sequence. pass the function 2 arguements, the first being the sequence, and=20 the second arguement being the index you want deleted. eg: pass the function ( "Hello" , 3 ) and it returns = "Helo" eg: pass the function ( {1,2,3,4,5}, 2 ) and it returns = {1,3,4,5} eg: pass the function ( { {1,1},{2,2},{3,3} }, 1 ) and it returns = {{2,2},{3,3}} (for this example, dont worry about invalid indexes being passed for the second element, unless you really want to tackle that as well) (this function can be created with a single line of euphoria code) 3: create a minimum() function which returns the lowest VALUE contained within a sequence. eg: pass the function {1,4,8,12,2,-4,-8,422} and it returns -8 (for a real challenge, code this function with one line of code... it = can be done) 4: create a maximum() function... see above, but return the highest = VALUE. (for a real challenge, code this function with one line of code... it = can be done) 5: create a trim() function (also often referred to as a mid() function) = that returns the indexes of a sequence contained between a range of = indexes. pass the function 3 parameters, a sequence of data, the low index = number and the high index number. every index/value from 1 up to the low = index number will thusly be truncated, and every index/value from the high index = number to the end of the sequence will be truncated. (the word inclusive = becomes real important here ) eg: pass the function ( {1,2,3,4,5,6,7,8,9}, 2, 6 ) and it returns = {2,3,4,5,6} eg: pass the function ( {9,8,7,6,5,4,3,2,1}, 2, 6 ) and it returns = {8,7,6,5,4} eg: pass the function ( {"john", "mary", "frank", "bill", "beanie", = "weenie"}, 2, 5) and it returns { "mary", "frank", "bill", "beanie" } eg: pass the function ("Mary had a little lamb that she really didn't = like much", 6, 22) and it returns "had a little lamb" (i think i counted that right = =3D] ) (this can be coded in one line, if we assume the low/high index numbers = are always proper) 6: create a boolean (true/false) function that can analyze any euphoria = object and determine if it is within a range of passed values, called = IsInRange().=20 the function should return a 1 or a 0 (true or false) as applicable = to each value(s) of any object passed to it. the function should accept three parameters, an object containing = data, the low end allowable value and the high end allowable value. the inputted data type should match the outputted data type, ergo: if = an atom was passed, an atom should be returned, and if a sequence was passed, = then a sequence of RESULTS should be returned. eg: pass the function ( 9, 4, 10 ) and it returns 1 eg: pass the function ( -3, 12, 100) and it returns 0 eg: pass the function ( {100,103, 110, 123, 140}, 105, 125 ) and it = returns {0, 0, 1, 1, 0} (this function can also be coded in a single line, and there is no need = to worry about bad values being sent to it, as the only way to crash this = function, if written properly, would be to pass a sequence to the second or third parameter, = and we will not worry about that for this task as euphoria won't even let = the program run if the function was used in that manner by a coder using this function) -------------------------------------------------------------------------= answers are below this -------------------------------------------------------------------------= -------------------------------------------------------------------------= NO PEEKING!!! -------------------------------------------------------------------------= -------------------------------------------------------------------------= sure you wanna peek?????????? -------------------------------------------------------------------------= 1: reverse=20 there can be some arguement here about how deep we should recurse.... also there is at least 2 other ways to do this, that are much more = efficient speed wise, but considerably more ardous to code, and the following is the most straightforward to understand and implement, imho. lastly, take note that it works on atoms or sequences, both :) function reverse(object data) sequence backwards=20 if atom(data) then return data end if backwards =3D {} for i =3D length(data) to 1 by -1 do backwards =3D append(backwards, data[i]) end for return backwards end function 2:delete this is a classic one-liner in euphoria and really shows off EU's power this can also be modified to work with any data type/object and I will leave that as another exercise for you :) function delete(sequence data, integer where) return data[1..where-1] & data[where+1..length(data)] end function 3:minimum this one is rather straightforward.... once again, we have an issue as to how deep we should recurse and this one can also work with any data type... also, there was a brilliant solution to this problem posted in the archives like a year or two ago, i believe by carl white, solving this problem for -any- data type, and -all- depths of recursion,=20 with using only a single line of code... i cannot quite remember how that line went off the top of my head... function minimum(object data) atom lowest if atom(data) then return data end if lowest =3D data[1] for i =3D 2 to length(data) do if lowest > data[i] then lowest =3D data[i] end if end for return lowest end function =20 4:maximum see above, change the > to <...etc 5:trim hrm ;) one liner ;) just a modification of delete is all :) function trim(sequence data, integer low, integer high) return data[low..high] end function 6:IsInRange this one is actually rather handy for processing user input for example: if IsInRange(UserChoice, 0, 10) then .... blah its valid = input take note, this works for sequences and atoms, and is capable of infinite depth recursion as needed, tricky! =3D]=20 who says euphoria doesn't own, eh? (this is a modification of the principle that carl white introduced for = min/max) function IsInRange(object data, atom low, atom high) return (data>=3Dlow ) and (data<=3Dhigh) end function ------=_NextPart_000_00BE_01C005A4.2D538E80 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2> <DIV> </DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:cyberego at QTA.PAKNET.COM.PK"=20 title=3Dcyberego at QTA.PAKNET.COM.PK>Asif Masood Baloch</A> </DIV> <DIV><FONT face=3DArial size=3D2>I've done quite homework on EU = programming and i=20 want you friends to help me evaluate myself. Send me small programming = tasks=20 so that i can have feedback. It will be=20 appreciated.</FONT></DIV></BLOCKQUOTE>here are a couple 'easy' tasks to=20 challenge your coding skills...</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>naturally, looking up the answer in a = library would=20 be 'cheating' ;)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>try to code them as best you can = yourself=20 :)</FONT><FONT face=3DArial size=3D2></FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>some of them can be done in = Euphoria with=20 a single line of</FONT></DIV> <DIV><FONT face=3DArial size=3D2>code within a = function....</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>there may be (indeed!) more then one = way to=20 implement each</FONT></DIV> <DIV><FONT face=3DArial size=3D2>of these challenges, and included many = lines down=20 in this email</FONT></DIV> <DIV><FONT face=3DArial size=3D2>are some potential solutions for each = of these=20 tasks/challenges...</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>1: create a reverse() function that = reverses the=20 order of any sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function {1,2,3,4,5} and = it returns=20 {5,4,3,2,1}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function=20 "Hello" and it returns "elloH"</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>2: create a delete() function that = removes any=20 element of a sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> pass the function 2 = arguements,=20 the first being the sequence, and </FONT></DIV> <DIV><FONT face=3DArial size=3D2> the second arguement = being the=20 index you want deleted.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( =20 "Hello" =20 , 3 ) and it = returns=20 "Helo"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( =20 {1,2,3,4,5}, 2 ) = and it=20 returns {1,3,4,5}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( { = {1,1},{2,2},{3,3} }, 1 )=20 and it returns {{2,2},{3,3}}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(for this example, dont worry about = invalid indexes=20 being passed for the</FONT></DIV> <DIV><FONT face=3DArial size=3D2> second element, unless you really = want to=20 tackle that as well)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(this function can be created with a = single line of=20 euphoria code)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>3: create a minimum() function which = returns the=20 lowest VALUE contained</FONT></DIV> <DIV><FONT face=3DArial size=3D2> within a = sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function = {1,4,8,12,2,-4,-8,422} and it=20 returns -8</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(for a real challenge, code this = function with one=20 line of code... it can be done)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>4: create a maximum() function... see = above, but=20 return the highest VALUE.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial size=3D2>(for a real challenge, code this = function with one=20 line of code... it can be done)</FONT></DIV> <DIV> </DIV></FONT></DIV> <DIV><FONT face=3DArial size=3D2>5: create a trim() function (also often = referred to=20 as a mid() function) that</FONT></DIV> <DIV><FONT face=3DArial size=3D2> returns the indexes = of a=20 sequence contained between a range of indexes.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> pass the function 3 = parameters,=20 a sequence of data, the low index number</FONT></DIV> <DIV><FONT face=3DArial size=3D2> and the high index = number. =20 every index/value from 1 up to the low index number</FONT></DIV> <DIV><FONT face=3DArial size=3D2> will thusly be = truncated, and=20 every index/value from the high index number</FONT></DIV> <DIV><FONT face=3DArial size=3D2> to the end of the = sequence will=20 be truncated. (the word inclusive becomes</FONT></DIV> <DIV><FONT face=3DArial size=3D2> real important = here =20 )</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( = {1,2,3,4,5,6,7,8,9}, 2, 6 )=20 and it returns {2,3,4,5,6}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( = {9,8,7,6,5,4,3,2,1}, 2, 6 )=20 and it returns {8,7,6,5,4}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( {"john", = "mary", "frank",=20 "bill", "beanie", "weenie"}, 2, 5)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> and it returns = { "mary",=20 "frank", "bill", "beanie" }</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ("Mary had a = little lamb that=20 she really didn't like much", 6, 22)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> and it returns = "had a=20 little lamb" (i think i counted that right =3D] )</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(this can be coded in one line, if we = assume the=20 low/high index numbers are always proper)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>6: create a boolean (true/false) = function that can=20 analyze any euphoria object and</FONT></DIV> <DIV><FONT face=3DArial size=3D2> determine if it is within = a range of=20 passed values, called IsInRange(). </FONT></DIV> <DIV><FONT face=3DArial size=3D2> the function should return = a</FONT><FONT face=3DArial size=3D2> 1 or a 0 (true or false) as = applicable to each=20 value(s)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> of any object passed to=20 it.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> the function should accept = three=20 parameters, an object containing data, the low</FONT></DIV> <DIV><FONT face=3DArial size=3D2> end allowable value and = the high end=20 allowable value.</FONT></DIV> <DIV><FONT face=3DArial size=3D2> the inputted data type = should match=20 the outputted data type, ergo: if an atom</FONT></DIV> <DIV><FONT face=3DArial size=3D2> was passed, an atom should = be=20 returned, and if a sequence was passed, then</FONT></DIV> <DIV><FONT face=3DArial size=3D2> a sequence of RESULTS = should be=20 returned.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( 9, 4, 10 ) and = it returns=20 1</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( -3, 12, 100) = and it returns=20 0</FONT></DIV> <DIV><FONT face=3DArial size=3D2>eg: pass the function ( {100,103, 110, = 123, 140},=20 105, 125 ) and it returns {0, 0, 1, 1, 0}</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(this function can also be coded in a = single line,=20 and there is no need to worry</FONT></DIV> <DIV><FONT face=3DArial size=3D2>about bad values being sent to it, as = the only way=20 to crash this function, if written</FONT></DIV> <DIV><FONT face=3DArial size=3D2>properly, would be to pass a sequence = to the second=20 or third parameter, and</FONT></DIV> <DIV><FONT face=3DArial size=3D2>we will not worry about that for this = task as=20 euphoria won't even let the program run</FONT></DIV> <DIV><FONT face=3DArial size=3D2>if the function was used in that manner = by a coder=20 using this function)</FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial=20 ---------</FONT></DIV></FONT></DIV> <DIV><FONT face=3DArial size=3D2>answers are below this</FONT></DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial=20 ---------</FONT></DIV></FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial=20 ---------</FONT></DIV> <DIV>NO PEEKING!!!</DIV> <DIV> <DIV><FONT face=3DArial=20 ---------</FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> <DIV><FONT face=3DArial=20 ---------</FONT></DIV> <DIV>sure you wanna peek??????????</DIV> <DIV> <DIV><FONT face=3DArial=20 ---------</FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV></DIV></DIV></DIV></FONT></DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>1: reverse </FONT></DIV> <DIV><FONT face=3DArial size=3D2>there can be some arguement here about = how deep we=20 should recurse....</FONT></DIV> <DIV><FONT face=3DArial size=3D2>also there is at least 2 other ways to = do this,=20 that are much more efficient</FONT></DIV> <DIV><FONT face=3DArial size=3D2> speed wise, but considerably more = ardous to=20 code, and the following is</FONT></DIV> <DIV><FONT face=3DArial size=3D2> the most straightforward to = understand and=20 implement, imho.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>lastly, take note that it works on = atoms or=20 sequences, both :)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>function reverse(object = data)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>sequence backwards </FONT></DIV> <DIV><FONT face=3DArial size=3D2> if atom(data) then return = data end=20 if</FONT></DIV> <DIV><FONT face=3DArial size=3D2> backwards =3D = {}</FONT></DIV> <DIV><FONT face=3DArial size=3D2> for i =3D length(data) to = 1 by -1=20 do</FONT></DIV> <DIV><FONT face=3DArial size=3D2> = backwards =3D=20 append(backwards, data[i])</FONT></DIV> <DIV><FONT face=3DArial size=3D2> end for</FONT></DIV> <DIV><FONT face=3DArial size=3D2> return = backwards</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end function</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>2:delete</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this is a classic one-liner in euphoria = and really=20 shows off EU's power</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this can also be modified to work with = any data=20 type/object and I will</FONT></DIV> <DIV><FONT face=3DArial size=3D2>leave that as another exercise for you=20 :)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>function delete(sequence data, integer=20 where)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> return data[1..where-1] &=20 data[where+1..length(data)]</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end function</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>3:minimum</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this one is rather = straightforward....</FONT></DIV> <DIV><FONT face=3DArial size=3D2>once again, we have an issue as to how = deep we=20 should recurse and</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this one can also work with any data=20 type...</FONT></DIV> <DIV><FONT face=3DArial size=3D2>also, there was a brilliant solution to = this=20 problem posted in the</FONT></DIV> <DIV><FONT face=3DArial size=3D2>archives like a year or two ago, i = believe by carl=20 white, solving</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this problem for -any- data type, and = -all- depths=20 of recursion, </FONT></DIV> <DIV><FONT face=3DArial size=3D2>with using only a single line of=20 code...</FONT></DIV> <DIV><FONT face=3DArial size=3D2>i cannot quite remember how that line = went off the=20 top of my head...</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>function minimum(object = data)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom lowest</FONT></DIV> <DIV><FONT face=3DArial size=3D2> if atom(data) then return = data end=20 if</FONT></DIV> <DIV><FONT face=3DArial size=3D2> lowest =3D = data[1]</FONT></DIV> <DIV><FONT face=3DArial size=3D2> for i =3D 2 to = length(data)=20 do</FONT></DIV> <DIV><FONT face=3DArial size=3D2> = if lowest=20 > data[i] then lowest =3D data[i] end if</FONT></DIV> <DIV><FONT face=3DArial size=3D2> end for</FONT></DIV> <DIV><FONT face=3DArial size=3D2> return lowest</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end function</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>4:maximum</FONT></DIV><FONT = face=3DArial size=3D2> <DIV><FONT face=3DArial size=3D2>see above, change the > to=20 <...etc</FONT></DIV> <DIV> </DIV> <DIV>5:trim</FONT></DIV> <DIV><FONT face=3DArial size=3D2>hrm ;) one liner ;) just a modification = of delete=20 is all :)</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>function trim(sequence data, integer = low, integer=20 high)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> return = data[low..high]</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end function</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>6:IsInRange</FONT></DIV> <DIV><FONT face=3DArial size=3D2>this one is actually rather handy for = processing=20 user input</FONT></DIV> <DIV><FONT face=3DArial size=3D2>for example: if IsInRange(UserChoice, = 0, 10) then=20 .... blah its valid input</FONT></DIV> <DIV><FONT face=3DArial size=3D2>take note, this works for sequences and = atoms, and=20 is capable of</FONT></DIV> <DIV><FONT face=3DArial size=3D2>infinite depth recursion as needed, = tricky! =3D]=20 </FONT></DIV> <DIV><FONT face=3DArial size=3D2>who says euphoria doesn't own, = eh?</FONT></DIV> <DIV><FONT face=3DArial size=3D2>(this is a modification of the = principle that carl=20 white introduced for min/max)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>function IsInRange(object data, atom = low, atom=20 high)</FONT></DIV> <DIV><FONT face=3DArial size=3D2> return (data>=3Dlow ) = and=20 (data<=3Dhigh)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>end function</FONT></DIV> ------=_NextPart_000_00BE_01C005A4.2D538E80--