Sha256: f50014441b06c0f5c19b5e7544a94ee1528c1e1b1efed271eda3319b7922cf41

Contents?: true

Size: 718 Bytes

Versions: 162

Compression:

Stored size: 718 Bytes

Contents

fun chunkify chunkSz s =
  let
    val sz = size s

    fun chunker 0 _   = chunker chunkSz (substring (s, 0, chunkSz))
      | chunker i acc =
          if sz = i
          then acc
          else if sz - i < chunkSz
               then acc ^ " " ^ substring (s, i, size s - i)
               else chunker (i + chunkSz) (acc ^ " " ^ substring (s, i, chunkSz))
  in
    if chunkSz > sz
    then s
    else chunker 0 ""
  end

fun cipher c =
  let
    open Char
    val n = ord #"z" + ord #"a"
    val c = toLower c
  in
    if isAlpha c
    then (toString o chr) (n - ord c)
    else if isDigit c
         then toString c
         else ""
  end

val decode = String.translate cipher
val encode = (chunkify 5) o decode

Version data entries

162 entries across 162 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.118 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.117 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.116 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.115 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.114 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.113 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.111 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.110 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.109 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.108 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.107 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.106 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.105 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.104 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.103 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.102 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.101 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.100 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.99 tracks/sml/exercises/atbash-cipher/example.sml