from Hacker News

John McCarthy’s collection of numerical facts for use in elisp programs

by chrchr on 9/7/23, 3:52 PM with 79 comments

  • by jaykru on 9/7/23, 4:56 PM

    "It contains a lot of units conversions and also astronomical facts that I needed for some research on moving Mars to a more temperate location."

    lmfao, anywhere I can read more about McCarthy's plans for this?

  • by dkbrk on 9/7/23, 9:09 PM

    This might come in handy but it's much inferior to the frink units file [0] which is much more complete, more rigorous, and includes dimensions.

    [0]: https://frinklang.org/frinkdata/units.txt

  • by agnosticmantis on 9/7/23, 6:56 PM

    Some may find it interesting that John McCarthy coined the term Artificial Intelligence and was called a/the father of AI before the deep learning folks took over. This AI referred to the symbolic flavor not the connectionist one.

    Nowadays (god-)fathers of AI are Geoff Hinton and Yann LeCun and others, but 20 years ago things were very different…

  • by Bostonian on 9/7/23, 5:35 PM

    I guess if you want a library for linear algebra operations in Lisp, you just write them yourself. From McCarthy's collection:

    ;;; multiplying a matrix by a column vector (defun mvmult (matrix vector) (list (scap (nth 0 matrix) vector) (scap (nth 1 matrix) vector)))

    ;;; sum of two vectors (defun vplus (vec1 vec2) (list (+ (nth 0 vec1) (nth 0 vec2)) (+ (nth 1 vec1) (nth 1 vec2))))

    ;;; difference of two vectors (defun vminus (vec1 vec2) (list (- (nth 0 vec1) (nth 0 vec2)) (- (nth 1 vec1) (nth 1 vec2))))

    ;;; scalar product of two vectors (defun scap (vec1 vec2) (+ (* (nth 0 vec1) (nth 0 vec2)) (* (nth 1 vec1) (nth 1 vec2))))

    ;;; product of scalar and vector (defun svmult (sca vec) (list (* sca (nth 0 vec)) (* sca (nth 1 vec))))

    ;;; sum of a list of vectors (defun addup (veclist) (if (null veclist) zerovec (vplus (car veclist) (addup (cdr veclist)))))

    (defconst zerovec '(0 0) "zero vector with two components"1)

    ;;; length of a vector (defun length (x) (sqrt (+ (expt (nth 0 x) 2) (expt (nth 1 x) 2))))

    (defconst Imatrix '((1.0 0.0) (0.0 1.0)) "unit 2x2 matrix")

    (defun smmult (sca matrix) (list (svmult sca (nth 0 matrix)) (svmult sca (nth 1 matrix))))

    (defun mplus (mat1 mat2) (list (vplus (nth 0 mat1) (nth 0 mat2)) (vplus (nth 1 mat1) (nth 1 mat2))))

    (defun mminus (mat1 mat2) (list (vminus (nth 0 mat1) (nth 0 mat2)) (vminus (nth 1 mat1) (nth 1 mat2))))

    (defun mmult (mat1 mat2) (list (list (scap (nth 0 mat1) (col 0 mat1)) (scap (nth 0 mat1) (col 1 mat1))) (list (scap (nth 1 mat1) (col 0 mat1)) (scap (nth 1 mat1) (col 1 mat1)))))

    (defun multiplyup (matlist) (if (null matlist) Imatrix (mmult (car matlist) (multiplyup (car matlist) (multiplyup (cdr (matlist)))))))

  • by mckn1ght on 9/7/23, 7:50 PM

    I made a GitHub repo mirroring it: https://github.com/armcknight/john-mccarthy-numerical-facts

    Also saw someone else just added it to one of theirs: https://github.com/bbarclay7/bb-emacs/blob/5858823bb033be113...

  • by nxobject on 9/7/23, 7:57 PM

    Now we know: John McCarthy used (x)emacs. Clearly an important revelation in the ongoing browser wars. /s (and not to minimize how genuinely interesting this is)
  • by bitwize on 9/7/23, 6:41 PM

    What's interesting to me is that the creator of Lisp found Emacs Lisp acceptable for practical general use. (Although as noted this file can be loaded verbatim into Common Lisp and work fine.)
  • by shric on 9/8/23, 1:11 PM

    Some of the constants have changed over the years.

    > (setq avogadro 6.0221367e23) ; Avogadro number

    This is now standardized to exactly 6.02214076e23

  • by thsksbd on 9/7/23, 8:23 PM

    Very cool, but I wonder why did he define foot as:

    (setq foot (* 0.3048 m))

    And not

    (setq foot (* 12 inch))

    It comes to the same thing, but inch is defined in metric as 2.54 cm and the foot is a derived unit of the inch. But this way it clearly spells out the dependency.

    Im not criticizing, it was his library for his use, I'm just wondering if there is there a deeper meaning beyond "God enough"?

  • by Exuma on 9/8/23, 3:09 AM

    One thing I always wonder is how people throughout history, on famous historic codebases etc, can indent things.... 90% the way, and then out of dozes of things correct there will be 3 things that are painfully off. Man, just indent them all the way if youre going to do it halfway

    Ive seen this in dennis richie code, doom code, etc

    Am i the only person who sees these things stand out like a sore thumb? It would drive me mad. They either all have to be not aligned, or aligned, but not 90%

  • by aj7 on 9/7/23, 7:09 PM

    Ok, a warmer Mars is desirable. But is Mars, in earth’s orbit, but on the opposite side of the sun, really closer?
  • by kagevf on 9/8/23, 7:07 AM

    So, I know that elisp has historically lacked lexical scope, so setting variables without a prefix has the potential for name clashes since even a variable setq'd into existence inside a defun will be added to the global namespace.

    I did an experiment to double check it's still true in a recent-ish emacs:

      (defun my-fun ()
        (setq test-123-456 'this-is-a-test))
    
      (my-fun)
    
      test-123-456 => this-is-a-test
    
    There is some information in the info file under elisp about lexical binding, but you can just use let to keep variables in a lexical scope.

      (defun my-other-fun ()
        (let ((test-789 'this-is-another-test))
          test-789))
    
      (my-other-fun)
    
      test-789 => *** Eval error ***  Symbol’s value as variable is void: test-789
  • by CyberDildonics on 9/8/23, 3:51 AM

    Are equations being renamed to 'numerical facts' now?
  • by Exuma on 9/8/23, 3:18 AM

    pony := 1 floz

    jigger := 1.5 floz