SurrealNumbers
SurrealNumbers.canonicaliseSurrealNumbers.expandSurrealNumbers.generationSurrealNumbers.surreal2dagSurrealNumbers.surreal2dot
SurrealNumbers.canonicalise — Method
canonicalise(s::SurrealFinite)Convert a surreal number form into its equivalent canonical form. It performs the conversion by converting to a Rational and then back to a Surreal.
Examples
julia> pf( canonicalise( convert(SurrealFinite, 1) - convert(SurrealFinite, 1) ) )
{ ∅ | ∅ }SurrealNumbers.expand — Method
expand(x::SurrealFinite; level=0)Writes a surreal as a string with varying levels of expansion.
Arguments
x::SurrealFinite: the number of elements to expandlevel=0: the amount of expansion- 0 : write shorthand if it exists, or $\{ X_L \| X_R \}$ if not
- 1 : $\{ X_L \| X_R \}$
- 2 : expand out $X_L$ and $X_R$ recursively
Examples
julia> expand( convert(SurrealFinite, 2))
"2"
julia> expand( convert(SurrealFinite, 2); level=1)
"{ 1 | ∅ }"
julia> expand( convert(SurrealFinite, 2); level=2)
"{ { { ∅ | ∅ } | ∅ } | ∅ }"SurrealNumbers.generation — Method
generation(x::SurrealFinite)Finds the birthday of a surreal number, which is 1 + the max of any of its components.
Arguments
x::SurrealFinite: the number to operate on
julia> generation( convert(SurrealFinite, 1) )
1SurrealNumbers.surreal2dag — Method
surreal2dag(x::SurrealFinite; direction::String="forward")
surreal2dag(io::IO, x::SurrealFinite; direction::String="forward")Writes a surreal representation as a DAG out in DOT format for drawing using GraphVis, and returns the number of nodes in the graph. Returns the number of nodes in the graph.
Arguments
io::IO: output stream, default is stdoutx::SurrealFinite: the number to write outdirection::String="forward": by default arrows point towards parents ("forward"), to go other way use "back"
Examples
julia> surreal2dag(convert(SurrealFinite, 0))
digraph "0.0" {
node_1 [shape=none,margin=0,label=
<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR><TD CELLPADDING="5pt" COLSPAN="2"><o>0</o></TD></TR>
<TR><TD PORT="L"> Ø </TD><TD PORT="R"> Ø </TD></TR>
</TABLE>>,
];
}
1SurrealNumbers.surreal2dot — Method
surreal2dot(x::SurrealFinite)
surreal2dot(io::IO, x::SurrealFinite)Writes a surreal representation as a tree out in DOT format for drawing using GraphVis, and returns the number of nodes in the graph.
Arguments
io::IO: output stream, default is stdoutx::SurrealFinite: the number to write outdirection::String="forward": by default arrows point towards parents ("forward"), to go other way use "back"
Examples
julia> surreal2dot(convert(SurrealFinite, 1))
digraph "1.0" {
node_1 [shape=none,margin=0,label=
<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR><TD CELLPADDING="5pt" COLSPAN="2"><o>1</o></TD></TR>
<TR><TD PORT="L"> <TABLE BORDER="0" CELLBORDER="0" CELLPADDING="0"><TR><TD CELLPADDING="1pt" PORT="0,1"> <o>0</o> </TD> </TR></TABLE> </TD><TD PORT="R"> Ø </TD></TR>
</TABLE>>,
];
node_1:"0,1" -> node_2 [color="red3", dir=forward];
node_2 [shape=none,margin=0,label=<<B>0</B>>]
}
2