home *** CD-ROM | disk | FTP | other *** search
- --written by nigel garvey
- on rndIEEE(n)
- if (n mod 2) ^ 2 > 0.25 then return n div 0.5 - n div 1
- n div 1
- end rndIEEE
-
- --sqrt(2)
- on sqrt(n)
- return n ^ 0.5
- end sqrt
-
-
- to average(theList)
- set n to 0
- set tot to 0
- repeat with anItem in theList
- set n to n + 1
- set tot to tot + anItem
- end repeat
- return (tot / n)
- end average
-
-
- to scale(theList, scaleFactor)
- set outList to {}
- repeat with anItem in theList
- set end of outList to (anItem * scaleFactor)
- end repeat
- return outList
- end scale
-
- to offsetList(theList, theOffset)
- set outList to {}
- repeat with anItem in theList
- set end of outList to (anItem + theOffset)
- end repeat
- return outList
- end offsetList
-
- to listMinMax(theList)
- set lmin to item 1 of theList
- set lmax to item 1 of theList
- repeat with anItem in theList
- if anItem < lmin then set lmin to anItem
- if anItem > lmax then set lmax to anItem
- end repeat
- return {lmin, lmax}
- end listMinMax
-
-
- --written by Paul Berkowitz, March/01
- on hex2Dec(hexNum)
- set specChars to {"A", "B", "C", "D", "E", "F"}
- set hexChars to characters of hexNum
- set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, tab}
- set subText to "" & hexChars -- back to text, with tabs
- repeat with i from 1 to 6
- set specChar to item i of specChars
- set AppleScript's text item delimiters to {specChar}
- set textClumps to text items of subText
- set AppleScript's text item delimiters to {"" & (i + 10)}
- set subText to "" & textClumps
- end repeat
- set AppleScript's text item delimiters to {tab}
- set subChars to text items of subText
- set theResult to 0
- repeat with theDigit in subChars
- set theResult to 16 * theResult + theDigit
- end repeat
- set AppleScript's text item delimiters to tids
- return theResult
- end hex2Dec