Caesar cipher: Difference between revisions

m
(Added GW-BASIC and MSX Basic)
Line 4,069:
"uifsf jt b ujef jo uif bggbjst pg nfo"
</syntaxhighlight>
=={{header|Koka}}==
<syntaxhighlight lang="koka">
fun encode(s : string, shift : int)
fun encode-char(c)
if c < 'A' || (c > 'Z' && c < 'a') || c > 'z' return c
val base = if c < 'Z' then (c - 'A').int else (c - 'a').int
val rot = (base + shift) % 26
(rot.char + (if c < 'Z' then 'A' else 'a'))
s.map(encode-char)
 
fun decode(s: string, shift: int)
s.encode(0 - shift)
 
fun trip(s: string, shift: int)
s.encode(shift).decode(shift)
 
fun main()
"HI".encode(2).println
"HI".encode(20).println
"HI".trip(10).println
val enc = "The quick brown fox jumped over the lazy dog".encode(11)
enc.println
enc.decode(11).println
</syntaxhighlight>
{{out}}
<pre>
JK
BC
HI
Esp bftnv mczhy qzi ufxapo zgpc esp wlkj ozr
The quick brown fox jumped over the lazy dog
</pre>
 
=={{header|Kotlin}}==
<syntaxhighlight lang="scala">// version 1.0.5-2
Line 4,111 ⟶ 4,144:
Bright vixens jump; dozy fowl quack.
</pre>
 
=={{header|LabVIEW}}==
For readability, input is in all caps.<br/>{{VI snippet}}<br/>[[File:LabVIEW_Caesar_cipher.png]]
24

edits