Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Caesar-cipher/F-Sharp/caesar-cipher.fs
Normal file
13
Task/Caesar-cipher/F-Sharp/caesar-cipher.fs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
module caesar =
|
||||
open System
|
||||
|
||||
let private cipher n s =
|
||||
let shift c =
|
||||
if Char.IsLetter c then
|
||||
let a = (if Char.IsLower c then 'a' else 'A') |> int
|
||||
(int c - a + n) % 26 + a |> char
|
||||
else c
|
||||
String.map shift s
|
||||
|
||||
let encrypt n = cipher n
|
||||
let decrypt n = cipher (26 - n)
|
||||
Loading…
Add table
Add a link
Reference in a new issue