unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: emacs-devel@gnu.org
Subject: Re: Adding a generic mathematical library
Date: Sun, 21 Jul 2024 14:20:05 +0200	[thread overview]
Message-ID: <874j8j3pje.fsf@dataswamp.org> (raw)
In-Reply-To: trinity-fd7d33bd-2f4f-433a-adcf-0a98f9aefcbf-1721562803618@3c-app-mailcom-bs10

Christopher Dimech wrote:

> All depends on who wants to produce a first release that
> handles two initial mathematical classifications, and which
> helps others extend the library to other additional
> topic classification.

Here is arithmetic!

What more do we want? :)

Arithmetic:

(+ &rest numbers)
  Return sum of any number of arguments, which are numbers or markers.
  (+ 1 2)
    => 3
  (+ 1 2 3 4)
    => 10
-------------------------------------------------------------------------------

(- &rest numbers)
  Negate number or subtract numbers or markers and return the result.
  (- 3 2)
    => 1
  (- 6 3 2)
    => 1
-------------------------------------------------------------------------------

(* &rest numbers)
  Return product of any number of arguments, which are numbers or markers.
  (* 3 4 5)
    => 60
-------------------------------------------------------------------------------

(/ number &rest divisors)
  Divide number by divisors and return the result.
  (/ 10 5)
    => 2
  (/ 10 6)
    => 1
  (/ 10.0 6)
    => 1.6666666666666667
  (/ 10.0 3 3)
    => 1.1111111111111112
-------------------------------------------------------------------------------

(% x y)
  Return remainder of X divided by Y.
  (% 10 5)
    => 0
  (% 10 6)
    => 4
-------------------------------------------------------------------------------

(mod x y)
  Return X modulo Y.
  (mod 10 5)
    => 0
  (mod 10 6)
    => 4
  (mod 10.5 6)
    => 4.5
-------------------------------------------------------------------------------

(1+ number)
  Return NUMBER plus one.  NUMBER may be a number or a marker.
  (1+ 2)
    => 3
-------------------------------------------------------------------------------

(1- number)
  Return NUMBER minus one.  NUMBER may be a number or a marker.
  (1- 4)
    => 3

Predicates

(= number &rest numbers)
  Return t if args, all numbers or markers, are equal.
  (= 4 4)
    => t
  (= 4.0 4.0)
    => t
  (= 4 4.0)
    => t
  (= 4 4 4 4)
    => t
-------------------------------------------------------------------------------

(eql obj1 obj2)
  Return t if the two args are ‘eq’ or are indistinguishable numbers.
  (eql 4 4)
    => t
  (eql 4.0 4.0)
    => t
-------------------------------------------------------------------------------

(/= num1 num2)
  Return t if first arg is not equal to second arg.  Both must be numbers or markers.
  (/= 4 4)
    => nil
-------------------------------------------------------------------------------

(< number &rest numbers)
  Return t if each arg (a number or marker), is less than the next arg.
  (< 4 4)
    => nil
  (< 1 2 3)
    => t
-------------------------------------------------------------------------------

(<= number &rest numbers)
  Return t if each arg (a number or marker) is less than or equal to the next.
  (<= 4 4)
    => t
  (<= 1 2 2 3)
    => t
-------------------------------------------------------------------------------

(> number &rest numbers)
  Return t if each arg (a number or marker) is greater than the next arg.
  (> 4 4)
    => nil
  (> 3 2 1)
    => t
-------------------------------------------------------------------------------

(>= number &rest numbers)
  Return t if each arg (a number or marker) is greater than or equal to the next.
  (>= 4 4)
    => t
  (>= 3 2 2 1)
    => t
-------------------------------------------------------------------------------

(zerop number)
  Return t if NUMBER is zero.
  (zerop 0)
    => t
-------------------------------------------------------------------------------

(natnump object)
  Return t if OBJECT is a nonnegative integer.
  (natnump -1)
    => nil
  (natnump 0)
    => t
  (natnump 23)
    => t
-------------------------------------------------------------------------------

(cl-plusp number)
  Return t if NUMBER is positive.
  (cl-plusp 0)
    => nil
  (cl-plusp 1)
    => t
-------------------------------------------------------------------------------

(cl-minusp number)
  Return t if NUMBER is negative.
  (cl-minusp 0)
    => nil
  (cl-minusp -1)
    => t
-------------------------------------------------------------------------------

(cl-oddp integer)
  Return t if INTEGER is odd.
  (cl-oddp 3)
    => t
-------------------------------------------------------------------------------

(cl-evenp integer)
  Return t if INTEGER is even.
  (cl-evenp 6)
    => t
-------------------------------------------------------------------------------

(bignump object)
  Return t if OBJECT is a bignum.
  (bignump 4)
    => nil
  (bignump (expt 2 90))
    => t
-------------------------------------------------------------------------------

(fixnump object)
  Return t if OBJECT is a fixnum.
  (fixnump 4)
    => t
  (fixnump (expt 2 90))
    => nil
-------------------------------------------------------------------------------

(floatp object)
  Return t if OBJECT is a floating point number.
  (floatp 5.4)
    => t
-------------------------------------------------------------------------------

(integerp object)
  Return t if OBJECT is an integer.
  (integerp 5.4)
    => nil
-------------------------------------------------------------------------------

(numberp object)
  Return t if OBJECT is a number (floating point or integer).
  (numberp "5.4")
    => nil
-------------------------------------------------------------------------------

(cl-digit-char-p char &optional radix)
  Test if CHAR is a digit in the specified RADIX (default 10).
  (cl-digit-char-p 53 10)
    => 5
  (cl-digit-char-p 102 16)
    => 15

Operations

(max number &rest numbers)
  Return largest of all the arguments (which must be numbers or markers).
  (max 7 9 3)
    => 9
-------------------------------------------------------------------------------

(min number &rest numbers)
  Return smallest of all the arguments (which must be numbers or markers).
  (min 7 9 3)
    => 3
-------------------------------------------------------------------------------

(abs arg)
  Return the absolute value of ARG.
  (abs -4)
    => 4
-------------------------------------------------------------------------------

(float arg)
  Return the floating point number equal to ARG.
  (float 2)
    => 2.0
-------------------------------------------------------------------------------

(truncate arg &optional divisor)
  Truncate a floating point number to an int.
  (truncate 1.2)
    => 1
  (truncate -1.2)
    => -1
  (truncate 5.4 2)
    => 2
-------------------------------------------------------------------------------

(floor arg &optional divisor)
  Return the largest integer no greater than ARG.
  (floor 1.2)
    => 1
  (floor -1.2)
    => -2
  (floor 5.4 2)
    => 2
-------------------------------------------------------------------------------

(ceiling arg &optional divisor)
  Return the smallest integer no less than ARG.
  (ceiling 1.2)
    => 2
  (ceiling -1.2)
    => -1
  (ceiling 5.4 2)
    => 3
-------------------------------------------------------------------------------

(round arg &optional divisor)
  Return the nearest integer to ARG.
  (round 1.2)
    => 1
  (round -1.2)
    => -1
  (round 5.4 2)
    => 3
-------------------------------------------------------------------------------

(random &optional limit)
  Return a pseudo-random integer.
  (random 6)
    => 5

Bit Operations

(ash value count)
  Return integer VALUE with its bits shifted left by COUNT bit positions.
  (ash 1 4)
    => 16
  (ash 16 -1)
    => 8
-------------------------------------------------------------------------------

(logand &rest ints-or-markers)
  Return bitwise-and of all the arguments.
  (logand #b10 #b111)
    => #b10
-------------------------------------------------------------------------------

(logior &rest ints-or-markers)
  Return bitwise-or of all the arguments.
  (logior 4 16)
    => 20
-------------------------------------------------------------------------------

(logxor &rest ints-or-markers)
  Return bitwise-exclusive-or of all the arguments.
  (logxor 4 16)
    => 20
-------------------------------------------------------------------------------

(lognot number)
  Return the bitwise complement of NUMBER.  NUMBER must be an integer.
  (lognot 5)
    => -6
-------------------------------------------------------------------------------

(logcount value)
  Return population count of VALUE.
  (logcount 5)
    => 2

Floating Point

(isnan x)
  Return non-nil if argument X is a NaN.
  (isnan 5.0)
    => nil
-------------------------------------------------------------------------------

(frexp x)
  Get significand and exponent of a floating point number.
  (frexp 5.7)
    => (0.7125 . 3)
-------------------------------------------------------------------------------

(ldexp sgnfcand exponent)
  Return SGNFCAND * 2**EXPONENT, as a floating point number.
  (ldexp 0.7125 3)
    => 5.7
-------------------------------------------------------------------------------

(logb arg)
  Returns largest integer <= the base 2 log of the magnitude of ARG.
  (logb 10.5)
    => 3
-------------------------------------------------------------------------------

(ffloor arg)
  Return the largest integer no greater than ARG, as a float.
  (ffloor 1.2)
    => 1.0
-------------------------------------------------------------------------------

(fceiling arg)
  Return the smallest integer no less than ARG, as a float.
  (fceiling 1.2)
    => 2.0
-------------------------------------------------------------------------------

(ftruncate arg)
  Truncate a floating point number to an integral float value.
  (ftruncate 1.2)
    => 1.0
-------------------------------------------------------------------------------

(fround arg)
  Return the nearest integer to ARG, as a float.
  (fround 1.2)
    => 1.0

Standard Math Functions

(sin arg)
  Return the sine of ARG.
  (sin float-pi)
    => 1.2246467991473532e-16
-------------------------------------------------------------------------------

(cos arg)
  Return the cosine of ARG.
  (cos float-pi)
    => -1.0
-------------------------------------------------------------------------------

(tan arg)
  Return the tangent of ARG.
  (tan float-pi)
    => -1.2246467991473532e-16
-------------------------------------------------------------------------------

(asin arg)
  Return the inverse sine of ARG.
  (asin float-pi)
    => 0.0e+NaN
-------------------------------------------------------------------------------

(acos arg)
  Return the inverse cosine of ARG.
  (acos float-pi)
    => 0.0e+NaN
-------------------------------------------------------------------------------

(atan y &optional x)
  Return the inverse tangent of the arguments.
  (atan float-pi)
    => 1.2626272556789118
-------------------------------------------------------------------------------

(exp arg)
  Return the exponential base e of ARG.
  (exp 4)
    => 54.598150033144236
-------------------------------------------------------------------------------

(log arg &optional base)
  Return the natural logarithm of ARG.
  (log 54.59)
    => 3.9998507157936665
-------------------------------------------------------------------------------

(expt arg1 arg2)
  Return the exponential ARG1 ** ARG2.
  (expt 2 16)
    => 65536
-------------------------------------------------------------------------------

(sqrt arg)
  Return the square root of ARG.
  (sqrt -1)
    => -0.0e+NaN

-- 
underground experts united
https://dataswamp.org/~incal




  parent reply	other threads:[~2024-07-21 12:20 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
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 [this message]
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=874j8j3pje.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).