kurz/tests/rule110.qbl

160 lines
2.5 KiB
Plaintext

//valid,---------------------------------#
//--------------------------------##
//-------------------------------###
//------------------------------##-#
//-----------------------------#####
//----------------------------##---#
//---------------------------###--##
//--------------------------##-#-###
//-------------------------#######-#
//------------------------##-----###
//-----------------------###----##-#
//----------------------##-#---#####
//---------------------#####--##---#
//--------------------##---#-###--##
//-------------------###--####-#-###
//------------------##-#-##--#####-#
//-----------------########-##---###
//----------------##------####--##-#
//---------------###-----##--#-#####
//--------------##-#----###-####---#
//-------------#####---##-###--#--##
//------------##---#--#####-#-##-###
//-----------###--##-##---########-#
//----------##-#-######--##------###
//---------#######----#-###-----##-#
//--------##-----#---####-#----#####
//-------###----##--##--###---##---#
//------##-#---###-###-##-#--###--##
//-----#####--##-###-######-##-#-###
//----##---#-#####-###----########-#
//---###--####---###-#---##------###
//--##-#-##--#--##-###--###-----##-#
//-########-##-#####-#-##-#----#####
//##------######---########---##---#
//##-----##----#--##------#--###--##
//:END:
function bool bool bool => bool rule110
{
if
{
if
{
if
{
false
}
else
{
true
}
}
}
else
{
if
{
deq true
}
}
}
arr val { bool 34 }
33 true val.write
printArrays
function int => bool int check
{
0 dup 1 > -
}
function => fullApply
{
// 0 b c
0 1 false val.read val.read
0 rule110 val2.write
val.length 1 - 1 dup - req
val.read val.read false
rule110 val.length 1
req - req val2.write
true 1
while
{
// i-1 i
1 dup - req
// i a | i a i | a i b | i b a i 1
val.read dup val.read req dup 1
// i a b i+1 | i+1 i a b | i a b c
req swp + req req req val.read
// i d
req rule110
// i d i | i
dup val2.write
checkUp-1
}
deq
}
function int => bool int checkUp
{
// i+1 l i+1
1 + val.length dup < req
}
function int => bool int checkUp-1
{
// i+1 l 1 | l 1 i+1 | i+1 l-1 i+1
1 + val.length 1 req - dup
// i+1 b
< req
}
arr val2 { bool 34 }
function => copyArrays
{
true 0
while
{
dup val2.read
dup val.write
checkUp
}
deq
}
function bool => str boolToSym
{
if
{
"#"
}
else
{
"-"
}
}
function => printArrays
{
true 0
while
{
dup val.read req boolToSym req print
checkUp
}
deq
"" println
}
true 33
while
{
fullApply
copyArrays
printArrays
check
}
deq