Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: d22f857a60
Fetching contributors…

Cannot retrieve contributors at this time

file 73 lines (48 sloc) 1.831 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
%include "string.h"

-- IO

putStr (x:String) -> Unit =
    foreign Unit "putStr" (x:String)

putStrLn (x:String) -> Unit =
    putStr(append(x,"\n"))

readStr () -> String =
    foreign String "readStr" ()

intToStr (x:Int) -> String =
    foreign String "intToStr" (x:Int)

strToInt (x:String) -> Int =
    foreign String "strToInt" (x:String)

printInt (x:Int) -> Unit =
  let foo:Unit = foreign Unit "printInt" (x:Int) in unit

-- String operations

append (x:String, y:String) -> String =
    foreign String "append" (x:String, y:String)

length (x:String) -> String =
    foreign Int "strlen" (x:String)

index (x:String, i:Int) -> Char =
    foreign Int "strIndex" (x:String, i:Int)

-- Big number arithmetic

addBig (x:BigInt, y:BigInt) -> BigInt =
   foreign BigInt "addBigInt" (x:BigInt, y:BigInt)

subBig (x:BigInt, y:BigInt) -> BigInt =
   foreign BigInt "subBigInt" (x:BigInt, y:BigInt)

mulBig (x:BigInt, y:BigInt) -> BigInt =
   foreign BigInt "mulBigInt" (x:BigInt, y:BigInt)

divBig (x:BigInt, y:BigInt) -> BigInt =
   foreign BigInt "divBigInt" (x:BigInt, y:BigInt)

modBig (x:BigInt, y:BigInt) -> BigInt =
   foreign BigInt "modBigInt" (x:BigInt, y:BigInt)

eqBig (x:BigInt, y:BigInt) -> Bool =
   foreign Int "eqBigInt" (x:BigInt, y:BigInt)

ltBig (x:BigInt, y:BigInt) -> Bool =
   foreign Int "ltBigInt" (x:BigInt, y:BigInt)

gtBig (x:BigInt, y:BigInt) -> Bool =
   foreign Int "gtBigInt" (x:BigInt, y:BigInt)

leBig (x:BigInt, y:BigInt) -> Bool =
   foreign Int "leBigInt" (x:BigInt, y:BigInt)

geBig (x:BigInt, y:BigInt) -> Bool =
   foreign Int "geBigInt" (x:BigInt, y:BigInt)

printBig (x:BigInt) -> Unit =
   foreign Unit "printBigInt" (x:BigInt)

bigIntToStr (x:BigInt) -> String =
    foreign String "bigIntToStr" (x:BigInt)

strToBigInt (x:String) -> Int =
    foreign String "strToBigInt" (x:String)
Something went wrong with that request. Please try again.