[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Functions with multiple optional arguments
From: |
Emanuel Berg |
Subject: |
Re: Functions with multiple optional arguments |
Date: |
Tue, 25 Oct 2022 07:25:15 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> `cl-defun' is Elisp, if you need it or not is up to you ...
Here is an example how it's done in Elisp only.
Hey, never to late to return to the old pen-and-paper RPGs!
Actually I don't want to do that ...
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/dice.el
(require 'cl-lib)
(cl-defun dice (&optional (sides 6) (num 1))
(let ((sum 0))
(dotimes (_ num) (cl-incf sum (1+ (random sides))))
sum) )
;; (dice) ; 1D6, 1-6
;; (dice 3) ; 1D3, 1-3
;; (dice 3 2) ; 2D3, 2-6
--
underground experts united
https://dataswamp.org/~incal
- RE: [External] : Re: Functions with multiple optional arguments, (continued)
Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/17
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/17
- Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/18
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/20
- Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/22
- Re: Functions with multiple optional arguments, Jean Louis, 2022/10/23
- Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/24
- Re: Functions with multiple optional arguments,
Emanuel Berg <=
Re: Functions with multiple optional arguments, Emanuel Berg, 2022/10/17