add existing documentation

This commit is contained in:
2024-11-02 15:11:00 +00:00
parent d5c41cbbaa
commit ac92c5317e
9 changed files with 1066 additions and 0 deletions

65
doc/sample/CaesarCipher.im Executable file
View File

@@ -0,0 +1,65 @@
package net.doorstuck.test
cout put:'Encode a string with a Caesar cipher.'
message = ''
while true do
cout print:'Message to encode: '
cout flush
cin get:message
if message != '' then
break
end
end
shiftWidth = 0
while true do
cout print:'Shift size: '
cout flush
shiftStr = ''
cin get:shiftStr
if shiftStr == '' then
continue
end
try
shiftWidth = Int parse:shiftStr
catch (#err:number_format, err)
continue
end
break
end
encodedMessage = ''
for c in message do
i = c toOrdinal
sub = 0
if i >= 65 && i <= 90 then
sub = 65
elif i >= 97 && i <= 122 then
sub = 97
else
continue
end
i -= sub
i += shiftWidth
if i >= 26 then
i -= 26
end
c2 = i toChar
encodedMessage += c2
end
cout put:encodedMessage