Wednesday, April 27, 2011

This Sentence is False

In FreeBASIC, a functional demonstration of "This sentence is false" as a binary logarithm using a recursive function... This is the most perfect proof that I can muster of a double binary. Who needs evidence when you have proof?


Original post:

function CutSwap ( byref txt as string, byval idx0 as integer, byval idx1 as integer, byref newtxt as string ) as string

dim as string firsthalf = LEFT(txt,idx0), secondhalf = RIGHT(txt,len(txt)-(idx1+1))
return firsthalf + newtxt + secondhalf

end function

function ThisSentenceIsFalse ( byref s as string, byval it as integer ) as string
if it<1 then return s
dim as string res = CutSwap( s, InStr( "This sentence", s)-1, len("This sentence"), s & " " )
return ThisSentenceIsFalse ( res, it-1 ) & " "
end function

? ThisSentenceIsFalse ( "This sentence is false", 7 )
? 2^7

No comments:

Post a Comment