string
Pos.equal
Section titled “Pos.equal”def Pos.equal (p : Pos) (q : Pos) : BoolWhether two binary positive numbers are equal, compared bit by bit.
Bin.equal
Section titled “Bin.equal”def Bin.equal (a : Bin) (b : Bin) : BoolWhether two binary natural numbers are equal.
Pos.toNat
Section titled “Pos.toNat”def Pos.toNat (p : Pos) : NatA binary positive number as a natural number.
Pos.ofNat
Section titled “Pos.ofNat”def Pos.ofNat (bits : Nat) (n : Nat) : PosA positive natural number in binary, the least significant bit outermost; bits bounds the number of bits.
Char.code
Section titled “Char.code”def code (c : Char) : NatThe code point of a character.
Char.ofCode
Section titled “Char.ofCode”def ofCode (n : Nat) : CharThe character of a code point (64 bits are enough for any code point).
Char.equal
Section titled “Char.equal”def equal (c : Char) (d : Char) : BoolWhether two characters are the same code point.
Char.ofDigit
Section titled “Char.ofDigit”def ofDigit (d : Nat) : CharThe digit character of a number from 0 to 9.
Char.positionIn
Section titled “Char.positionIn”def positionIn (c : Char) (cs : List Char) (i : Nat) : Option NatThe position of a character in a list, counting from i.
Char.digit
Section titled “Char.digit”def digit (c : Char) : Option NatThe value of a decimal digit character, or none for any other character.
Char.inRange
Section titled “Char.inRange”def inRange (low : Nat) (high : Nat) (c : Char) : BoolWhether a character’s code point is from low to high.
Char.isDigit
Section titled “Char.isDigit”def isDigit (c : Char) : BoolWhether a character is an ASCII decimal digit.
Char.isUpper
Section titled “Char.isUpper”def isUpper (c : Char) : BoolWhether a character is an ASCII uppercase letter.
Char.isLower
Section titled “Char.isLower”def isLower (c : Char) : BoolWhether a character is an ASCII lowercase letter.
Char.isAlpha
Section titled “Char.isAlpha”def isAlpha (c : Char) : BoolWhether a character is an ASCII letter.
Char.isAlphanumeric
Section titled “Char.isAlphanumeric”def isAlphanumeric (c : Char) : BoolWhether a character is an ASCII letter or digit.
Char.isSpace
Section titled “Char.isSpace”def isSpace (c : Char) : BoolWhether a character is whitespace: a space, a tab, a carriage return or a newline.
Char.toUpper
Section titled “Char.toUpper”def toUpper (c : Char) : CharAn ASCII lowercase letter in uppercase; any other character as it is.
Char.toLower
Section titled “Char.toLower”def toLower (c : Char) : CharAn ASCII uppercase letter in lowercase; any other character as it is.
Nat.hexDigit
Section titled “Nat.hexDigit”def Nat.hexDigit (d : Nat) : CharThe lowercase hexadecimal digit of a number from 0 to 15.
Decimal.lastDigit
Section titled “Decimal.lastDigit”def lastDigit (n : Nat) : CharThe last decimal digit of a number, as a character.
Decimal.digits
Section titled “Decimal.digits”def digits (fuel : Nat) (n : Nat) (rest : List Char) : List CharThe decimal digits of n in front of rest, by repeated division by 10; fuel only bounds the recursion (it
stops when n < 10).
Decimal.read
Section titled “Decimal.read”def read (cs : List Char) (read : Nat) : Option NatThe number decimal digits give, read onto read; none at a character that is not a digit.
Nat.decimal
Section titled “Nat.decimal”def Nat.decimal (n : Nat) : StringThe decimal digits of a natural number (toString n is the same).
String.chars
Section titled “String.chars”def chars (s : String) : List CharThe characters of a string.
String.append
Section titled “String.append”def append (a : String) (b : String) : StringTwo strings one after the other.
String.length
Section titled “String.length”def length (s : String) : NatThe number of characters of a string (not of bytes).
String.sameChars
Section titled “String.sameChars”def sameChars (cs : List Char) (ds : List Char) : BoolWhether two lists of characters are the same, character by character.
String.equal
Section titled “String.equal”def equal (a : String) (b : String) : BoolWhether two strings have the same characters.
String.concat
Section titled “String.concat”def concat (xs : List String) : StringThe strings of a list one after the other; f"..." expands to it.
String.charsAfter
Section titled “String.charsAfter”def charsAfter (start : List Char) (cs : List Char) : Option (List Char)The characters after a prefix, if the characters start with it.
String.cutAt
Section titled “String.cutAt”def cutAt (sep : List Char) (fuel : Nat) (cs : List Char) (piece : List Char) : List (List Char)Characters cut at every occurrence of a separator (not empty), the piece so far in reverse; fuel bounds the
recursion.
String.split
Section titled “String.split”def split (s : String) (sep : String) : List StringA string cut at every occurrence of a separator, left to right; an empty separator gives the whole string.
String.join
Section titled “String.join”def join (sep : String) (xs : List String) : StringThe strings of a list with a separator between each two.
String.isEmpty
Section titled “String.isEmpty”def isEmpty (s : String) : BoolWhether a string has no characters.
String.lines
Section titled “String.lines”def lines (s : String) : List StringThe lines of a string, cut at each newline.
String.words
Section titled “String.words”def words (s : String) : List StringThe words of a string: the pieces between spaces that are not empty.
String.toNat
Section titled “String.toNat”def toNat (s : String) : Option NatThe number a non-empty string of decimal digits writes, or none.
String.startsWith
Section titled “String.startsWith”def startsWith (s : String) (start : String) : BoolWhether a string starts with a prefix.
String.reversed
Section titled “String.reversed”def reversed (s : String) : StringA string’s characters in reverse order.
String.endsWith
Section titled “String.endsWith”def endsWith (s : String) (ending : String) : BoolWhether a string ends with a suffix.
String.take
Section titled “String.take”def take (n : Nat) (s : String) : StringThe first n characters of a string.
String.drop
Section titled “String.drop”def drop (n : Nat) (s : String) : StringA string without its first n characters.
String.dropSpaces
Section titled “String.dropSpaces”def dropSpaces (cs : List Char) : List CharCharacters without the whitespace at their start.
String.trim
Section titled “String.trim”def trim (s : String) : StringA string without the whitespace at its start and end.
String.positionIn
Section titled “String.positionIn”def positionIn (part : List Char) (cs : List Char) (i : Nat) : Option NatThe position of the first occurrence of a part in characters, counting from i.
String.indexOf
Section titled “String.indexOf”def indexOf (s : String) (part : String) : Option NatThe character position of the first occurrence of a part in a string, if it occurs.
String.contains
Section titled “String.contains”def contains (s : String) (part : String) : BoolWhether a part occurs in a string.
String.replacedIn
Section titled “String.replacedIn”def replacedIn (part : List Char) (replacement : List Char) (fuel : Nat) (cs : List Char) : List CharCharacters with every occurrence of a part (not empty) replaced, left to right; fuel bounds the recursion.
String.replace
Section titled “String.replace”def replace (s : String) (part : String) (replacement : String) : StringA string with every occurrence of a part replaced, left to right and not overlapping; an empty part changes nothing.
String.toUpper
Section titled “String.toUpper”def toUpper (s : String) : StringA string with its ASCII letters in uppercase.
String.toLower
Section titled “String.toLower”def toLower (s : String) : StringA string with its ASCII letters in lowercase.
String.repeat
Section titled “String.repeat”def repeat (n : Nat) (s : String) : StringA string n times.
String.padding
Section titled “String.padding”def padding (n : Nat) (pad : String) : List CharThe first n characters of a padding repeated.
String.padStart
Section titled “String.padStart”def padStart (n : Nat) (pad : String) (s : String) : StringA string padded at its start up to n characters (a longer one as it is).
String.padEnd
Section titled “String.padEnd”def padEnd (n : Nat) (pad : String) (s : String) : StringA string padded at its end up to n characters (a longer one as it is).
String.nonEmptyLines
Section titled “String.nonEmptyLines”def nonEmptyLines (s : String) : List StringThe lines of a string that are not empty after trimming, trimmed.
ToString
Section titled “ToString”class ToString (A : Type)Types whose values can be shown as a string.
toStringNat
Section titled “toStringNat”instance toStringNat : ToString NatA natural number in decimal.
toStringBool
Section titled “toStringBool”instance toStringBool : ToString Booltrue and false.
toStringString
Section titled “toStringString”instance toStringString : ToString StringA string as itself.
toStringList
Section titled “toStringList”instance toStringList {A : Type} {{d : ToString A}} : ToString (List A)A list as [a, b, c].
toStringOption
Section titled “toStringOption”instance toStringOption {A : Type} {{d : ToString A}} : ToString (Option A)An option as none or some a.
Decimal.hasDigits
Section titled “Decimal.hasDigits”def hasDigits (cs : List Char) : BoolWhether there is at least one digit.
Decimal.bltAddLeft
Section titled “Decimal.bltAddLeft”def bltAddLeft (x : Nat) (n : Nat) (k : Nat) (h : Nat.blt x n = true) : Nat.blt x (add k n) = truebltSuccR k times: x < n implies x < k + n.
Decimal.bltOfAddLeft
Section titled “Decimal.bltOfAddLeft”def bltOfAddLeft (m : Nat) (n : Nat) (k : Nat) (h : Nat.blt (add k m) n = true) : Nat.blt m n = truebltPredL k times: k + m < n implies m < n.
Decimal.timesTenPlus
Section titled “Decimal.timesTenPlus”def timesTenPlus (d : Nat) (r : Nat) : Natd * 10 + r.
Decimal.shifted
Section titled “Decimal.shifted”def shifted (v : Nat) (n : Nat) : NatA value with the last digit of n appended: v * 10 + n mod 10.
Decimal.belowTimesTen
Section titled “Decimal.belowTimesTen”def belowTimesTen (d : Nat) (r : Nat) : Nat.blt d (succ (Decimal.timesTenPlus d r)) = trued < d * 10 + r + 1.
Decimal.quotientBelow
Section titled “Decimal.quotientBelow”def quotientBelow (D : Nat) (R : Nat) (k : Nat) (h : Nat.blt (Decimal.timesTenPlus D R) (succ k) = true) (hr : Nat.blt R 10 = true) (e : Nat.blt (Decimal.timesTenPlus D R) 10 = false) : Nat.blt D k = trueThe next digit has fuel: from D * 10 + R < k + 1, R < 10 and D * 10 + R not below 10, D < k.
Decimal.quotientHasFuel
Section titled “Decimal.quotientHasFuel”def quotientHasFuel (n : Nat) (k : Nat) (h : Nat.blt n (succ k) = true) (e : Nat.blt n 10 = false) : Nat.blt (Nat.div n 10) k = trueDropping the last decimal digit of n (at least 10) leaves fuel: n < k + 1 implies n / 10 < k.
Decimal.digitOfDigit
Section titled “Decimal.digitOfDigit”def digitOfDigit (d : Nat) (h : Nat.blt d 10 = true) : Char.digit (Char.ofDigit d) = some dReading back one digit: the digit of Char.ofDigit d is d, for d < 10.
Decimal.value
Section titled “Decimal.value”def value (fuel : Nat) (read : Nat) (n : Nat) : NatThe value read back from Decimal.digits, with the same fuel and recursion, onto read.
Decimal.digitsAfter
Section titled “Decimal.digitsAfter”def digitsAfter (small : Bool) (fewer : Nat) (n : Nat) (rest : List Char) : List CharDecimal.digits after its comparison with 10.
Decimal.valueAfter
Section titled “Decimal.valueAfter”def valueAfter (small : Bool) (fewer : Nat) (read : Nat) (n : Nat) : NatDecimal.value after its comparison with 10.
Decimal.readDigit
Section titled “Decimal.readDigit”def readDigit (m : Option Nat) (rest : List Char) (read : Nat) : Option NatDecimal.read of a looked-up digit.
Decimal.readOne
Section titled “Decimal.readOne”def readOne (d : Nat) (h : Nat.blt d 10 = true) (rest : List Char) (read : Nat) : Decimal.read (cons (Char.ofDigit d) rest) read = Decimal.read rest (add (mul read 10) d)Reading a digit d < 10 multiplies the value by ten and adds d.
Decimal.ReadsAfter
Section titled “Decimal.ReadsAfter”def ReadsAfter (small : Bool) (fewer : Nat) (n : Nat) (rest : List Char) (read : Nat) : TypeThe statement of Decimal.readDigits after the comparison with 10.
Decimal.readDigits
Section titled “Decimal.readDigits”def readDigits (fuel : Nat) : (n : Nat) -> (rest : List Char) -> (read : Nat) -> Decimal.read (Decimal.digits fuel n rest) read = Decimal.read rest (Decimal.value fuel read n)Reading what Decimal.digits writes is reading on with the value of n, for any fuel.
Decimal.ValueAfter
Section titled “Decimal.ValueAfter”def ValueAfter (small : Bool) (fewer : Nat) (n : Nat) : TypeThe statement of Decimal.valueOfDigits after the comparison with 10.
Decimal.valueOfDigits
Section titled “Decimal.valueOfDigits”def valueOfDigits (fuel : Nat) : (n : Nat) -> Nat.blt n fuel = true -> Decimal.value fuel 0 n = nWith enough fuel (n < fuel), the value read back is n.
Decimal.digitsNotEmpty
Section titled “Decimal.digitsNotEmpty”def digitsNotEmpty (fuel : Nat) : (n : Nat) -> (c : Char) -> (rest : List Char) -> Decimal.hasDigits (Decimal.digits fuel n (cons c rest)) = trueDecimal.digits onto a non-empty list is not empty.
Decimal.decimalNotEmpty
Section titled “Decimal.decimalNotEmpty”def decimalNotEmpty (n : Nat) : Decimal.hasDigits (Decimal.digits (succ n) n nil) = trueThe decimal digits of a number are not empty.
Decimal.toNatOf
Section titled “Decimal.toNatOf”def toNatOf (cs : List Char) : Option NatString.toNat of characters.
Decimal.toNatOfNotEmpty
Section titled “Decimal.toNatOfNotEmpty”def toNatOfNotEmpty (cs : List Char) (h : Decimal.hasDigits cs = true) : Decimal.toNatOf cs = Decimal.read cs 0On characters that are not empty, String.toNat reads them.
String.toNatDecimal
Section titled “String.toNatDecimal”def String.toNatDecimal (n : Nat) : String.toNat (Nat.decimal n) = some nReading back the decimal digits gives the number.