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.180 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.179 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.178 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.177 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.176 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.175 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.174 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.173 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.172 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.171 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.170 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.169 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.167 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.166 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.165 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.164 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.163 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.162 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.161 tracks/sml/exercises/atbash-cipher/example.sml
trackler-2.2.1.160 tracks/sml/exercises/atbash-cipher/example.sml