Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
32
Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel
Normal file
32
Task/Caesar-cipher/SequenceL/caesar-cipher.sequencel
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import <Utilities/Sequence.sl>;
|
||||
import <Utilities/Conversion.sl>;
|
||||
|
||||
lowerAlphabet := "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
upperAlphabet := "abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
caesarEncrypt(ch, key) :=
|
||||
let
|
||||
correctAlphabet :=
|
||||
lowerAlphabet when some(ch = lowerAlphabet)
|
||||
else
|
||||
upperAlphabet;
|
||||
|
||||
index := Sequence::firstIndexOf(correctAlphabet, ch);
|
||||
|
||||
newIndex := (index + key - 1) mod 26 + 1;
|
||||
in
|
||||
ch when not(some(ch = lowerAlphabet) or some(ch = upperAlphabet))
|
||||
else
|
||||
correctAlphabet[newIndex];
|
||||
|
||||
caesarDecrypt(ch, key) := caesarEncrypt(ch, 26 - key);
|
||||
|
||||
main(args(2)) :=
|
||||
let
|
||||
key := Conversion::stringToInt(args[2]);
|
||||
encrypted := caesarEncrypt(args[1], key);
|
||||
decrypted := caesarDecrypt(encrypted, key);
|
||||
in
|
||||
"Input: \t" ++ args[1] ++ "\n" ++
|
||||
"Encrypted:\t" ++ encrypted ++ "\n" ++
|
||||
"Decrypted:\t" ++ decrypted;
|
||||
Loading…
Add table
Add a link
Reference in a new issue