;;; kkk-random.el --- Function randomize things -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Vinicius Teshima ;; Author: Vinicius Teshima ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Random Things ;;; Code: (defun kkk-list-get-random (list) "Get a random item from LIST." (elt list (random (length list)))) (defun kkk-random-char () "Return a random char." (char-to-string (+ 33 (random 94)))) (defun kkk-random-string (length) "Create a random string with LENGTH chars." (let ((x "")) (dolist (_ (make-list length 0)) (setq x (concat x (kkk-random-char))) ) x ) ) (defun kkk-random-date (year) "Return a random date string on iso format (YYYY-MM-DD) using YEAR as year." (when (stringp year) (concat year "-" (int-to-string (+ (cl-random 12) 1)) "-" (int-to-string (+ (cl-random 30) 1))) ) ) (provide 'kkk-random) ;;; kkk-random.el ends here