Exploring all the ways ONE and ZERO can interact as text or as numbers

This is an idea I played with from another project. It was used to generate a quick set of truths that could be used for other things. One really useful part of this was it’s ability to produce and run a ‘‘virtual-script’’ using the ‘‘run script’’ command.

Basically, it uses 1 and 0 as examples (which could be any number such as pi), then runs them thru a sieve of operators to produce a list of possible interactions and results.

Obviously ‘‘all’’ the ways would require a bigger internet. For example, it might generate some unexpected patterns if each character was converted into it’s hexadecimal or binary version prior to running the gauntlet.

If it is useful to you, let me know. If you find an interesting way to modify it, I’d be interested in that too!


set OPRTRS to {"<", "≤", "=", "≠", "≥", ">", "^", "*", "÷", "+", "-", "&", " mod ", " div ", "/", " & ", " and ", " or ", " not ", "is", "contains"}

#GENERATE A STRING FOR EACH POSSIBLE EQUATION of ONE and ZERO
set rprt to return
set vals to {0, 1}
repeat with n1 in vals
	repeat with n2 in vals
		repeat with op in OPRTRS
			set strng to "(" & n1 & " " & op & " " & n2 & ")"
			set rslt to my runSCRPT(strng)
			set rprt to rprt & strng & "=" & rslt & return
		end repeat
	end repeat
end repeat
return rprt --show all results

# RUN STRING AS A SCRIPT, GET RESULT
on runSCRPT(strng)
	try
		set rslt to run script strng
	on error err
		return "err"
	end try
	return rslt
end runSCRPT

(* set SAMPLE_RESULT to "
(0 < 0)=false
(0 ≤ 0)=true
(0 = 0)=true
(0 ≠ 0)=false
(0 ≥ 0)=true
(0 > 0)=false
(0 ^ 0)=1.0
(0 * 0)=0
(0 ÷ 0)=err
(0 + 0)=0
(0 - 0)=0
(0 & 0)=00
(0  mod  0)=err
(0  div  0)=err
(0 / 0)=err
(0  &  0)=00
(0  and  0)=err
(0  or  0)=err
(0  not  0)=err
(0  is  0)=true
(0 contains 0)=true
(0 < 1)=true
(0 ≤ 1)=true
(0 = 1)=false
(0 ≠ 1)=true
(0 ≥ 1)=false
(0 > 1)=false
(0 ^ 1)=0.0
(0 * 1)=0
(0 ÷ 1)=0.0
(0 + 1)=1
(0 - 1)=-1
(0 & 1)=01
(0  mod  1)=0
(0  div  1)=0
(0 / 1)=0.0
(0  &  1)=01
(0  and  1)=err
(0  or  1)=err
(0  not  1)=err
(0  is  1)=false
(0 contains 1)=false
(1 < 0)=false
(1 ≤ 0)=false
(1 = 0)=false
(1 ≠ 0)=true
(1 ≥ 0)=true
(1 > 0)=true
(1 ^ 0)=1.0
(1 * 0)=0
(1 ÷ 0)=err
(1 + 0)=1
(1 - 0)=1
(1 & 0)=10
(1  mod  0)=err
(1  div  0)=err
(1 / 0)=err
(1  &  0)=10
(1  and  0)=err
(1  or  0)=err
(1  not  0)=err
(1  is  0)=false
(1 contains 0)=false
(1 < 1)=false
(1 ≤ 1)=true
(1 = 1)=true
(1 ≠ 1)=false
(1 ≥ 1)=true
(1 > 1)=false
(1 ^ 1)=1.0
(1 * 1)=1
(1 ÷ 1)=1.0
(1 + 1)=2
(1 - 1)=0
(1 & 1)=11
(1  mod  1)=0
(1  div  1)=1
(1 / 1)=1.0
(1  &  1)=11
(1  and  1)=err
(1  or  1)=err
(1  not  1)=err
(1  is  1)=true
(1 contains 1)=true
"*)

Model: Mac Pro, Yosemite
AppleScript: 2.7
Browser: Safari 601.2.7
Operating System: Mac OS X (10.13 Developer Beta 3)