tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
17
Task/Rot-13/Racket/rot-13.rkt
Normal file
17
Task/Rot-13/Racket/rot-13.rkt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/env racket
|
||||
#lang racket/base
|
||||
|
||||
(define (run i o)
|
||||
(for ([ch (in-producer regexp-match #f #rx#"[a-zA-Z]" i 0 #f o)])
|
||||
(define b (bytes-ref (car ch) 0))
|
||||
(define a (if (< b 96) 65 97))
|
||||
(write-byte (+ (modulo (+ 13 (- b a)) 26) a))))
|
||||
|
||||
(require racket/cmdline)
|
||||
(command-line
|
||||
#:help-labels "(\"-\" specifies standard input)"
|
||||
#:args files
|
||||
(for ([f (if (null? files) '("-") files)])
|
||||
(if (equal? f "-")
|
||||
(run (current-input-port) (current-output-port))
|
||||
(call-with-input-file f ( (i) (run i (current-output-port)))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue