Skip to content

Commit

Permalink
Added constructor method to build Sequence from Instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
jakewilliami committed Feb 20, 2022
1 parent c5e9b51 commit 1aea8cf
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/goto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Instruction(i::Integer, j::Integer...) = Instruction((i, j...))
Given a tuple or a list of values, the value of the instruction is the pair of all inputs.
---
### Examples
```julia
Expand Down Expand Up @@ -103,7 +101,7 @@ struct Sequence <: ProgrammeCompoment
For any ``d \in \mathbb{N}``, the sequence code of a sequence ``(a_0,a_1,\ldots,a_{d-1}) \in \mathbb{N}^d``, denoted by ``[a_0,a_1,\ldots,a_{d-1}]``, is
```math
\left\langle d, \left\langle a a_0,a_1,\ldots,a_{d-1}\right\rangle\right\rangle
q = \left\langle d, \left\langle a a_0,a_1,\ldots,a_{d-1}\right\rangle\right\rangle
```
The struct has the following fields:
Expand All @@ -112,15 +110,14 @@ The struct has the following fields:
- `instructions::Tuple`
```julia
Sequence(q::Integer)
Sequence(t::Tuple)
Sequence(i::Integer, j::Tuple)
Sequence(q::Integer) # instructions_coded
Sequence(t::Tuple) # (seq_length, instructions_coded)
Sequence(seq_length::Integer, j::Tuple)
Sequence(i::Integer, j::Integer...)
Sequence(i::Instruction...)
```
The constructor methods for this struct decode the given value(s) into the sequence.
---
### Examples
Expand Down Expand Up @@ -162,6 +159,7 @@ struct Sequence <: ProgrammeCompoment

Sequence(i::Integer, j::Tuple) = Sequence(pair_tuple(i, pair_tuple(j...)))
Sequence(i::Integer, j::Integer...) = Sequence((i, tuple(j...)))
Sequence(i::Instruction...) = Sequence(length(i), Tuple(j.I for j in i))
end # end struct

@doc raw"""
Expand Down

0 comments on commit 1aea8cf

Please sign in to comment.