Re: Standard Euphoria Library Project
- Posted by David Cuny <dcuny at LANSET.COM> Feb 07, 2001
- 527 views
A couple more assorted routines that pop up in my code. I'd also suggest ripping the C structure tools out of Win32Lib and putting them in a seperate file. Apologies for the math routines not handling sequences. -- David Cuny function iif( integer test, object true, object false ) -- return true or false value, depending on test result -- both the true and false expressions will be evaluated! if test then return true else return false end if end function function remove_all( object o, sequence s ) -- remove all instances of o from s sequence new new = {} for i = 1 to length( s ) do if not equal( o, s[i] ) then new = append( new, s[i] ) end if end for return new end function function remove( integer i, sequence s) -- remove ith element from s return s[1..i-1] & s[i+1..length(s)] end function function fix( atom a ) -- convert an atom to an integer integer int -- get integer portion int = floor( a ) -- round up or down? if a - int >= 0.5 then int = int + 1 end if return int end function function abs( atom a ) -- return absolute value of a number if a > 0 then return a else return -a end if end function function min( integer i1, integer i2 ) -- return lesser of the two values if i1 < i2 then return i1 else return i2 end if end function function max( integer i1, integer i2 ) -- return larger of the two values if i1 > i2 then return i1 else return i2 end if end function