From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: Re: Adding a generic mathematical library
Date: Sun, 21 Jul 2024 07:19:02 +0200 [thread overview]
Message-ID: <87ikwz5nll.fsf@dataswamp.org> (raw)
In-Reply-To: E1sUqHm-00071h-59@fencepost.gnu.org
Richard Stallman wrote:
>> but I also have a math.el which I yank below if any of it
>> can be used.
>
> Most of the fnctions in this library are very close
> to trivial.
Oh, my! Eli thinks they are so exotic only I use them, RMS
thinks they are close to trivial.
But I have many more files, I'll see what I have that can
maybe impress you and Eli more.
I have already showed you math.el and perm.el, here are two
more. But I'll look thru it all some other day and make
a directory with all of them.
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/stats.el
(require 'cl-lib)
(defun decade ()
(interactive)
(cl-loop
with entries = ()
for d from 190 to 202
do (push (how-many (format "^.\\{14\\}%d[[:digit:]]" d)) entries)
finally (message "%s" (nreverse entries)) ))
(defun random-distribution (n sum &optional min no-error)
"Return a list of N random numbers.
\nThe sum of the numbers is SUM.
\nEvery number is at least MIN. (default: 0)
\nIf NO-ERROR, recompute unsolvable systems with MIN = 0. (default: nil)"
(or min (setq min 0))
(let ((min-share (* n min)))
(if (< sum min-share)
(if no-error
(random-distribution n sum)
(error "Bogus indata, unsolvable") )
(let ((vals (make-list n min))
(pool (- sum min-share)) )
(cl-loop while (< 0 pool)
do (cl-incf (nth (random n) vals))
(cl-decf pool) )
vals) )))
(defalias 'rd #'random-distribution)
;; (apply #'+ (rd 10 100 3)) ; sum is 100, OK
;; (rd 10 100) ; omitted/default min = 0, OK
;; (rd 10 100 10) ; border case, but OK
;; (rd 10 100 20) ; error: Bogus indata, unsolvable
;; (rd 10 100 20 t) ; unsolvable but no-error, recompute for min = 0
;;
;; 10 example distributions for
;; n = 10, sum = 100, and min = 3,
;; i.e. (rd 10 100 3):
;;
;; (12 8 8 10 7 6 19 9 7 14)
;; ( 8 12 7 12 9 10 9 9 12 12)
;; (14 6 15 11 9 9 6 8 11 11)
;; ( 8 12 7 9 10 9 10 13 10 12)
;; (12 12 15 6 10 8 6 10 14 7)
;; ( 9 7 10 8 11 10 9 10 13 13)
;; ( 7 13 13 10 13 10 5 13 5 11)
;; (13 8 6 9 13 8 11 7 10 15)
;; ( 7 10 5 6 17 14 8 10 14 9)
;; (11 10 8 9 11 10 14 11 8 8)
(provide 'stats)
;;; -*- lexical-binding: t -*-
;;
;; help from:
;; https://codereview.stackexchange.com/q/186840
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/str-to-bits.el
(require 'esh-util)
(defun num-to-bits (num)
(let ((s ""))
(while (> num 0)
(setq s (concat (number-to-string (logand num 1)) s))
(setq num (ash num -1)) )
(if (string= "" s)
"0"
s) ))
(defalias 'dec2bits #'num-to-bits)
(defalias 'char2bits #'num-to-bits)
(defun str-to-bits (str &optional delim)
(interactive "sString: ")
(or delim (setq delim " "))
(let ((bits))
(dolist (c (string-to-list str) (mapconcat #'eshell-stringify bits delim))
(push (num-to-bits c) bits) )))
;; (str-to-bits "What's up Emacs community?") ; 111111 1110000 1110101 [...]
(provide 'str-to-bits)
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2024-07-21 5:19 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 16:47 Add elisa to GNU ELPA Sergey Kostyaev
2024-07-16 12:54 ` Philip Kaludercic
2024-07-16 13:57 ` Sergey Kostyaev
2024-07-16 16:04 ` Philip Kaludercic
2024-07-16 16:35 ` Sergey Kostyaev
2024-07-17 13:21 ` Andrew Hyatt
2024-07-16 16:41 ` Sergey Kostyaev
2024-07-16 17:02 ` Philip Kaludercic
2024-07-16 17:47 ` Adding a generic mathematical library Philip Kaludercic
2024-07-16 22:06 ` Emanuel Berg
2024-07-17 2:54 ` Christopher Dimech
2024-07-17 5:58 ` Emanuel Berg
2024-07-19 16:16 ` Richard Stallman
2024-07-19 17:38 ` Christopher Dimech
2024-07-21 5:20 ` Emanuel Berg
2024-07-20 12:45 ` Max Nikulin
2024-07-20 13:53 ` Christopher Dimech
2024-07-21 5:19 ` Emanuel Berg [this message]
2024-07-21 6:15 ` Emanuel Berg
2024-07-21 7:40 ` Emanuel Berg
2024-07-21 8:45 ` Emanuel Berg
2024-07-21 8:29 ` Emanuel Berg
2024-07-21 7:27 ` Christopher Dimech
2024-07-21 8:03 ` Emanuel Berg
2024-07-21 9:14 ` Christopher Dimech
2024-07-21 9:48 ` Emanuel Berg
2024-07-21 11:20 ` Emanuel Berg
2024-07-21 11:53 ` Christopher Dimech
2024-07-21 12:10 ` Emanuel Berg
2024-07-21 12:27 ` Emanuel Berg
2024-07-21 12:46 ` Emanuel Berg
2024-07-21 13:03 ` Christopher Dimech
2024-07-21 13:17 ` Emanuel Berg
2024-07-21 14:33 ` Eli Zaretskii
2024-07-21 14:41 ` Christopher Dimech
2024-07-21 14:49 ` Eli Zaretskii
2024-07-21 14:58 ` Christopher Dimech
2024-07-21 15:02 ` Eli Zaretskii
2024-07-21 15:18 ` Christopher Dimech
2024-07-21 13:18 ` Christopher Dimech
2024-07-21 13:26 ` Emanuel Berg
2024-07-21 14:35 ` Christopher Dimech
2024-07-21 19:28 ` Emanuel Berg
2024-07-21 19:33 ` Emanuel Berg
2024-07-21 19:51 ` Emanuel Berg
2024-07-21 20:01 ` Emanuel Berg
2024-07-21 20:17 ` Emanuel Berg
2024-07-21 12:41 ` Christopher Dimech
2024-07-21 13:13 ` Emanuel Berg
2024-07-21 13:41 ` Emanuel Berg
2024-07-21 12:20 ` Emanuel Berg
2024-07-21 12:04 ` Emanuel Berg
2024-07-21 14:30 ` hypotenuse (was: Re: Adding a generic mathematical library) Emanuel Berg
2024-07-21 14:44 ` Eli Zaretskii
2024-07-21 15:00 ` Eli Zaretskii
2024-07-21 15:12 ` Christopher Dimech
2024-07-21 15:42 ` Eli Zaretskii
2024-07-21 16:13 ` Christopher Dimech
2024-07-21 15:54 ` hypotenuse Max Nikulin
2024-07-21 16:12 ` hypotenuse Eli Zaretskii
2024-07-21 16:17 ` hypotenuse Christopher Dimech
2024-07-21 19:01 ` hypotenuse (was: Re: Adding a generic mathematical library) Emanuel Berg
2024-07-21 19:13 ` Emanuel Berg
2024-07-21 17:38 ` tomas
2024-07-17 7:09 ` Adding a generic mathematical library Michael Heerdegen via Emacs development discussions.
2024-07-17 7:54 ` Philip Kaludercic
2024-07-17 7:56 ` Michael Heerdegen via Emacs development discussions.
2024-07-18 6:07 ` Emanuel Berg
2024-07-18 6:45 ` Christopher Dimech
2024-07-18 7:12 ` Emanuel Berg
2024-07-18 7:49 ` Christopher Dimech
2024-07-21 4:56 ` Emanuel Berg
2024-07-18 7:29 ` Eli Zaretskii
2024-07-18 7:57 ` Emanuel Berg
2024-07-18 9:03 ` Eli Zaretskii
2024-07-21 4:52 ` Emanuel Berg
2024-07-18 8:15 ` Emanuel Berg
2024-07-18 9:04 ` Eli Zaretskii
2024-07-18 9:13 ` Christopher Dimech
2024-07-21 4:59 ` Emanuel Berg
2024-07-19 13:22 ` Emanuel Berg
2024-07-19 16:12 ` Christopher Dimech
2024-07-19 16:15 ` Stefan Kangas
2024-07-19 16:29 ` Christopher Dimech
2024-07-19 16:16 ` Richard Stallman
2024-07-19 18:00 ` Christopher Dimech
2024-07-17 21:26 ` Add elisa to GNU ELPA Sergey Kostyaev
2024-07-17 22:12 ` Philip Kaludercic
2024-07-18 3:45 ` Sergey Kostyaev
2024-07-18 11:06 ` Sergey Kostyaev
-- strict thread matches above, loose matches on Subject: below --
2024-07-23 20:00 Adding a generic mathematical library Kepa
2024-07-25 4:19 ` Emanuel Berg
2024-07-25 11:32 ` Christopher Dimech
2024-07-25 14:20 ` Stefan Kangas
2024-07-25 15:16 ` T.V Raman
2024-07-25 15:34 ` Christopher Dimech
2024-07-25 17:12 ` Emanuel Berg
2024-07-25 17:25 ` Emanuel Berg
2024-07-25 14:24 ` Emanuel Berg
2024-07-25 15:49 ` Christopher Dimech
2024-07-25 17:23 ` Emanuel Berg
2024-07-27 14:57 Shouran Ma
2024-07-27 15:49 ` Emanuel Berg
2024-07-27 19:07 Shouran Ma
2024-07-27 19:23 ` Christopher Dimech
2024-07-28 0:29 ` Emanuel Berg
2024-07-28 10:58 ` Christopher Dimech
2024-07-28 11:39 ` Emanuel Berg
2024-07-28 12:28 ` Christopher Dimech
2024-07-28 13:02 ` Emanuel Berg
2024-07-30 2:53 ` Richard Stallman
2024-07-30 3:53 ` Emanuel Berg
2024-07-30 6:26 ` Christopher Dimech
2024-07-30 7:20 ` Emanuel Berg
2024-07-30 11:30 ` Christopher Dimech
2024-07-30 22:56 ` Emanuel Berg
2024-07-31 16:00 ` Michael Heerdegen via Emacs development discussions.
2024-07-31 21:15 ` Emanuel Berg
2024-08-01 6:05 ` Eli Zaretskii
2024-08-01 6:42 ` Emanuel Berg
2024-07-31 21:26 ` Emanuel Berg
2024-07-27 19:40 ` Christopher Dimech
2024-07-28 0:24 ` Emanuel Berg
2024-07-28 13:34 ` Immanuel Litzroth
2024-07-28 13:56 ` Christopher Dimech
2024-07-28 14:07 ` Emanuel Berg
2024-07-28 10:46 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ikwz5nll.fsf@dataswamp.org \
--to=incal@dataswamp.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).