Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int structure #228

Closed
julianhyde opened this issue Sep 24, 2024 · 0 comments
Closed

Int structure #228

julianhyde opened this issue Sep 24, 2024 · 0 comments

Comments

@julianhyde
Copy link
Collaborator

Implement the Int structure from the standard basis library. Per Moscow ML it has the following interface:

val precision : int option
val minInt    : int option
val maxInt    : int option

val ~         : int -> int              (* Overflow      *)
val *         : int * int -> int        (* Overflow      *)
val div       : int * int -> int        (* Div, Overflow *)
val mod       : int * int -> int        (* Div           *)
val quot      : int * int -> int        (* Div, Overflow *)
val rem       : int * int -> int        (* Div           *)
val +         : int * int -> int        (* Overflow      *)
val -         : int * int -> int        (* Overflow      *)
val >         : int * int -> bool
val >=        : int * int -> bool
val <         : int * int -> bool
val <=        : int * int -> bool
val abs       : int -> int              (* Overflow      *)
val min       : int * int -> int
val max       : int * int -> int

val sign      : int -> int
val sameSign  : int * int -> bool
val compare   : int * int -> order

val toInt     : int -> int
val fromInt   : int -> int
val toLarge   : int -> int
val fromLarge : int -> int

val scan      : StringCvt.radix 
                -> (char, 'a) StringCvt.reader -> (int, 'a) StringCvt.reader
val fmt       : StringCvt.radix -> int -> string

val toString  : int -> string
val fromString : string -> int option   (* Overflow      *)

Example use:

Int.compare;
> val it = fn : int * int -> order
Int.compare (2, 3);
> val it = LESS : order
Int.maxInt;
> val it = SOME 1073741823 : int option

The Int structure is an instance of the INTEGER signature in the Standard Basis Library but Morel does not currently have signatures.

julianhyde added a commit to julianhyde/morel that referenced this issue Sep 26, 2024
julianhyde added a commit that referenced this issue Sep 26, 2024
Implement the `Int` structure from the standard basis
library. (The `Int` structure is an instance of the `INTEGER`
signature in the Standard Basis Library but Morel does not
currently have signatures.)

Fixes #228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant