Commit c5946b85 authored by Kisaragi Hiu's avatar Kisaragi Hiu
Browse files

Add random-string

parent 7321bb28
#!/usr/bin/env racket
#lang racket
; vim: filetype=racket
; random-string [length]
(define charset (or (getenv "CHARSET")
(define (select-random-item lst #:ref-fn [ref-fn list-ref] #:length-fn [length-fn length])
(ref-fn lst (random (length-fn lst))))
(define (random-string [len 16])
(for/list ([i (in-range len)])
(select-random-item charset #:ref-fn string-ref #:length-fn string-length))))
(if (empty? (vector->list (current-command-line-arguments)))
(displayln (random-string))
(displayln (random-string (string->number (vector-ref (current-command-line-arguments) 0)))))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment