Implementation of John Conway's esoteric FRACTRAN programming language in Go.
# go get github.com/jgalilee/fractran
# go install github.com/jgalilee/fractran
Source file primes.ft
. The grammar currently disallows white space or new
lines.
17/91,78/85,19/51,23/38,29/33,77/29,95/23,77/19,1/17,11/13,13/11,15/14,15/2,55/1
Usage depends on whether there is a piped file. There is either one or two args depending. The last argument is the initial value of n.
The following two commands are equivalent.
# cat eg/primes.ft | fractran 2
# fractran eg/primes.ft 2
The internal package github.com/jgalilee/fractran/lang
exposes two types
the Program
type and the Parser
type. The Parser
type only accepts the
highly simplistic grammar as shown in the example.
The MIT License (MIT)
Copyright (c) 2015 Jack Galilee
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.