home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2001 June 15 / MACPEOPLE-2001-06-15.ISO.7z / MACPEOPLE-2001-06-15.ISO / オンラインウエア / 新着!オンラインウエア16 / KHyX.sit / KHyX / Modules / HMNumberTheory / stack_-1.xml < prev    next >
Extensible Markup Language  |  2001-03-08  |  5KB  |  20 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>1</cardCount>
  7.     <cardID>3631</cardID>
  8.     <listID>2129</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>416</width>
  14.         <height>240</height>
  15.     </cardSize>
  16.     <script>function binaryAND x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) AND (c2 = 1)) into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryANDfunction binaryOR x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) OR (c2 = 1)) into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryORfunction binaryXOR x,yput baseconvert(x,10,2) into bxput baseconvert(y,10,2) into byrepeat while (the number of chars in bx) < (the number of chars in by)put "0" before bxend repeatrepeat while (the number of chars in by) < (the number of chars in bx)put "0" before byend repeatput "" into bzrepeat with xx = 1 to (the number of chars in by)put char xx of bx into c1put char xx of by into c2put ((c1 = 1) OR (c2 = 1)) into boolif ((c1 = 1) AND (c2 = 1)) then put false into boolif bool then put "1" after bzif not bool then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryXORfunction binaryNOT xput baseconvert(x,10,2) into bxput "" into bzrepeat with xx = 1 to (the number of chars in bx)put char xx of bx into c1if c1 = 0 then put "1" after bzif c1 = 1 then put "0" after bzend repeatreturn baseconvert(bz,2,10)end binaryNOTfunction isPrime xif x < 2 then return "neither"if intgr(x) <> x then return "neither"if (x > 6) and (last char of x is in "024685") then return false -- cheating shortcutif (x < 7) then return item x of "neither,true,true,false,true,false,true" -- and anotherput true into bolrepeat with xx = 2 to intgr(sqrt(x))if (x/xx) = intgr(x/xx) then put false into bolend repeatreturn bolend isPrimefunction isComposite xif x < 2 then return "neither"if intgr(x) <> x then return "neither"return (not (isprime(x)))end isCompositefunction isPerfect xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return true -- cheating shortcutif x < 100000000 then return false -- and anotherif (factorSum(x)-x) = x then return truereturn falseend isPerfectfunction isAbundant xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return falsereturn (factorSum(x)-x) > xend isAbundantfunction isDeficient xput empty into factorListif x < 1 then return "neither"if intgr(x) <> x then return "neither"if comma & x & comma is in ",6,28,496,8128,33550336,8589869056,137438691328,2305843008139952128," then return falsereturn (factorSum(x)-x) < xend isDeficientfunction isHappy xif x < 0 then return "neither"if intgr(x) <> x then return "neither"put 0 into arepeat with i = 1 to (the number of chars in x)add (char i of x)^3 to aend repeatreturn (a = x)end isHappyfunction isPalindromic xput x into n1put empty into n2repeat with x = 1 to (the number of chars in n1)put char x of n1 before n2end repeatreturn (n1 = n2)end isPalindromicfunction isTriangular xreturn (sqrt((8*x)+1) = intgr(sqrt((8*x)+1)))end isTriangularfunction isSquare xreturn (sqrt(x) = intgr(sqrt(x)))end isSquarefunction isEven xreturn (x/2 = intgr(x/2))end isEvenfunction isOdd xreturn not isEven(x)end isOddfunction isPositive xreturn (x > 0)end isPositivefunction isNegative xreturn (x < 0)end isNegativefunction thePerfectness xif isAbundant(x) then return "1"if isDeficient(x) then return "-1"if isPerfect(x) then return "0"end thePerfectnessfunction thePolarity xreturn sgn(x)end thePolarity</script>
  17.     <background id="2751" file="background_2751.xml" name="" />
  18.     <card id="3631" file="card_3631.xml" marked="false" name="" owner="2751" />
  19. </stack>
  20.