GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    screwlisp (screwtape@mastodon.sdf.org)'s status on Monday, 17-Feb-2025 17:41:28 JST screwlisp screwlisp
    • Riley S. Faelan
    • DougMerritt (log😅 = 💧log😄)

    @riley @dougmerritt
    Yeah,
    (let ((alist '((:foo . bar) (:baz buz))))
    (cdr (assoc :foo alist)) ; -> bar
    (cadr (assoc :baz alist))) ; -> buz
    There isn't a lot of cost (well, one cons to nil) of using cadr or second instead of cdr. And then you could store other stuff in later positions of the list as well. When I only knew the definitions of assoc and pairlis, I mostly used cdr, but then in lisp code I've read, like you said, the cadr one seems more common in lots of places.

    In conversation about 3 months ago from mastodon.sdf.org permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 17:41:25 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • DougMerritt (log😅 = 💧log😄)

      @dougmerritt CDR coding was only really used on the Lisp Machine, which did not have kb of memory .. but rather megabytes. It also didn't save much, while lists are useful, for large sets of data there are better representations.

      @screwtape @riley@toot.cat

      In conversation about 3 months ago permalink
    • Embed this notice
      DougMerritt (log😅 = 💧log😄) (dougmerritt@mathstodon.xyz)'s status on Monday, 17-Feb-2025 17:41:27 JST DougMerritt (log😅 = 💧log😄) DougMerritt (log😅 = 💧log😄)
      in reply to
      • Riley S. Faelan

      @screwtape @riley
      As a historical note:

      > There isn't a lot of cost (well, one cons to nil)

      Back in the days when RAM was measured in kilobytes / kilowords, some implementations did in fact have space-optimized representations for short lists represented as small arrays.

      See cdr-coding
      https://en.wikipedia.org/wiki/CDR_coding

      That might still be in some implementations today, since its savings might be significant in large structures or in aiding cache locality.
       
      The first paper may well have been L. Peter Deutsch: A LISP Machine with Very Compact Programs. IJCAI 1973, Pages 697 - 703

      This is covered in 7.13 in the classic "Anatomy of Lisp", John Allen (1937-2022), 1978 (long out of print, and the author once replied to my query saying he didn't think it was worthwhile updating it for more modern times).

      Has a lot on implemention, but tends to talk about abstractions in terms of M-Expressions, which is no longer in style.

      ACM has it online:
      https://dl.acm.org/doi/pdf/10.5555/542865

      Glowing review of "Anatomy" on goodreads: https://www.goodreads.com/book/show/1537412.Anatomy_of_LISP

      "John Allen (1937-2022) and Anatomy of LISP" by Paul McJones
      https://mcjones.org/dustydecks/archives/2024/04/11/1249/

      In conversation about 3 months ago permalink

      Attachments



      1. Domain not in remote thumbnail source whitelist: images-na.ssl-images-amazon.com
        Anatomy of LISP
        McGraw-Hill Computer Science Series. McGraw-Hill Serie…
      2. No result found on File_thumbnail lookup.
        John Allen (1937-2022) and Anatomy of LISP
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 18:07:44 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to

      @screwtape I'll disagree with John Allen. Strongly. CAR/CDR are great abstractions on CONS cells.

      In conversation about 3 months ago permalink
    • Embed this notice
      screwlisp (screwtape@mastodon.sdf.org)'s status on Monday, 17-Feb-2025 18:07:45 JST screwlisp screwlisp
      in reply to
      • Alfred M. Szmidt

      @amszmidt
      Doug linked John Allen's book which spends about 50 pages asking people to please not use car and cdr as though they were intended as general list manipulation tools, even though they might be literally implemented as first and rest, since it's a failure of abstraction or something.

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 18:25:20 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to

      @screwtape FIRST/LAST .. make it confusing when working on improper lists. Which is why I disagree with Allen. CAR/CDR have very good names, and explain exactly what happens, similar with all the CnnnnR versions.

      In conversation about 3 months ago permalink
    • Embed this notice
      screwlisp (screwtape@mastodon.sdf.org)'s status on Monday, 17-Feb-2025 18:25:21 JST screwlisp screwlisp
      in reply to
      • Simon Brooke
      • Alfred M. Szmidt

      @amszmidt I might have garbled it, but he was talking about structured programming. So when the data structure being operated on is a cons cell, use car and cdr, and when the data structure being operated on is a list, use list functions like first and last (for example, but also consider something like subseq). I'm open to not necessarily agreeing with Allen's book (for undergraduates).
      @simon_brooke

      In conversation about 3 months ago permalink
    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Monday, 17-Feb-2025 20:31:29 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt

      @amszmidt @screwtape Hah, this reminds me of this craziness from my early days:

      • First is first, last is a list of last.

      • When given the list ((10 (20 30 40) 50) 60 70)), output the first of the last of the first of the last of the first element, and name the accessor.

      (The answer is 30, and CADADAR, but of course you all already knew that right away)

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 20:32:22 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson

      @ksaj This is a great example of why CnnnnR (and in turn CAR/CDR) work so well in Lisp.

      @screwtape

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 20:37:08 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson

      @ksaj Compare to ...

      (first (last (first (last (first ....)))))

      Brain hurts from counting, and FLFLF .. doesn't sound as nice. Specially when you have a list structure where it is relatively common to access that specific element.

      @screwtape

      In conversation about 3 months ago permalink
    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Monday, 17-Feb-2025 20:58:21 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt

      @amszmidt @screwtape I thought you'd like the example.

      It was one of the first things I learned (and definitely not the easiest way to learn!). I don't use it very often, but when I need it, it is so much nicer to look at. It just confuses the hell out of people who don't understand, or ignore the List part of LISp.

      Using CnnnnR accessors is awesome when coding something like a Sudoku solver, where you have to consider rows, blocks and columns.

      In conversation about 3 months ago permalink

      Attachments

      1. No result found on File_thumbnail lookup.
        example.it
        description
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 20:58:21 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson

      @ksaj Absolutley, and _if_ the names don't fit, DEFSUBST!

      @screwtape

      In conversation about 3 months ago permalink
    • Embed this notice
      lispwizard (lispwizard@techhub.social)'s status on Monday, 17-Feb-2025 21:01:29 JST lispwizard lispwizard
      in reply to
      • Alfred M. Szmidt

      @amszmidt @screwtape I still use cadr, cdar, cddar, etc. frequently when writing ad-hoc code to grovel through data; those would be cumbersome (to say the least) if they needed to be compositions of first and rest. I have also used cdr-coded lists, not only for space savings but to be able to refer to array data as a list (c.f. g-l-p) and to (in separate circumstances) interpolate less structured traditional cons list structure in the middle of compactly stored lists.

      Both these practices fall in the category of "infrequently applicable but very useful when they do apply". I find that this category as a whole seems to be diminishing. When I try to explain this category to colleagues (usually in conjunction with explaining why I did something the way I'd chosen), they usually say that they'd never remember that it would apply.

      In conversation about 3 months ago permalink
      Alfred M. Szmidt repeated this.
    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Monday, 17-Feb-2025 21:01:29 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt
      • lispwizard

      @lispwizard @amszmidt @screwtape Want to drive a Lisper mad? Mix them.

      (first (cadr (some-list)))

      lol.

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 21:01:39 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson
      • lispwizard

      @ksaj 😜 @lispwizard @screwtape

      In conversation about 3 months ago permalink
    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Monday, 17-Feb-2025 21:03:13 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt

      @amszmidt @screwtape I'm not an emacs guy, so I'll take your word on that. 😈

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Monday, 17-Feb-2025 21:03:13 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson

      @ksaj @screwtape Lisp Machine Lisp!

      In conversation about 3 months ago permalink
    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Monday, 17-Feb-2025 21:07:31 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt

      @amszmidt @screwtape Ah, much more cool than emacs.

      Just kidding. I like to rile peeps up sometimes. :ablobcatrainbow:

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Tuesday, 18-Feb-2025 02:50:47 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson
      • DougMerritt (log😅 = 💧log😄)

      @dougmerritt ok, instead of being a jerk .. where else was it used? @screwtape @ksaj

      In conversation about 3 months ago permalink
    • Embed this notice
      DougMerritt (log😅 = 💧log😄) (dougmerritt@mathstodon.xyz)'s status on Tuesday, 18-Feb-2025 02:50:49 JST DougMerritt (log😅 = 💧log😄) DougMerritt (log😅 = 💧log😄)
      in reply to
      • Karsten Johansson
      • Alfred M. Szmidt

      @screwtape
      Etymology doesn't necessarily prove anything, but it *is* pretty weird that "CAR" was the mnemonic for "Contents of A Register" and "CDR" for "Contents of D Register" -- literal machine registers, not originally an abstraction at all.

      BTW

      > CDR coding was only really used on the Lisp Machine

      That's 100% false.

      @amszmidt
      @ksaj

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Tuesday, 18-Feb-2025 02:52:24 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson
      • DougMerritt (log😅 = 💧log😄)

      @dougmerritt CDR was one of those things which the LispM hackers wanted to flush on the LispM cause it was just a pain in the ass .. slow, the benefits of it was nil.

      @screwtape @ksaj

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Tuesday, 18-Feb-2025 04:55:15 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson
      • DougMerritt (log😅 = 💧log😄)

      @dougmerritt A for address, D for decrement. It wasn’t for A/D. Etymology is clear from the IBM 704. Now care to substantial the “100% false” wrt where CDR coding was used?
      @screwtape @ksaj @riley@toot.cat

      In conversation about 3 months ago permalink
    • Embed this notice
      Alfred M. Szmidt (amszmidt@mastodon.social)'s status on Tuesday, 18-Feb-2025 15:05:16 JST Alfred M. Szmidt Alfred M. Szmidt
      in reply to
      • Karsten Johansson
      • Weekend Editor
      • lispwizard

      @weekend_editor Which is like on the CADR.

      But I wouldn't call DTP-NULL a WTF typ, since it is used for unbound variables.

      "Actually, a void binding contains a weird internal value, which the system interprets as meaning “there is no value here”. (This is the data type code dtp-null)." https://tumbleweed.nu/r/lm-3/uv/chinual.html#dtp_002dnull_002dvar

      DTP-TRAP on the other hand ...

      @ksaj @lispwizard @screwtape

      In conversation about 3 months ago permalink

      Attachments


    • Embed this notice
      Karsten Johansson (ksaj@infosec.exchange)'s status on Tuesday, 18-Feb-2025 15:05:18 JST Karsten Johansson Karsten Johansson
      in reply to
      • Alfred M. Szmidt
      • Weekend Editor
      • lispwizard

      @weekend_editor @lispwizard @amszmidt @screwtape Instead of ending with a NIL, it could be a WTF.

      In conversation about 3 months ago permalink
    • Embed this notice
      Weekend Editor (weekend_editor@mathstodon.xyz)'s status on Tuesday, 18-Feb-2025 15:05:18 JST Weekend Editor Weekend Editor
      in reply to
      • Karsten Johansson
      • Alfred M. Szmidt
      • lispwizard

      @ksaj @lispwizard @amszmidt @screwtape

      On the Symbolics system, the type tags were all encoded in the microcode source and recognized in the hardware (ok, really the microcode). The type tag names were constants whose names all began with "DTP-" (for "data type", probably).

      There was a type calld DTP-NULL (see below, page 7, though I think that's for the Ivory chip).

      It didn't *quite* mean WTF, but almost. :-)

      (No, it was not used this way.)

      https://bitsavers.org/pdf/symbolics/I_Machine/Lisp-Machine_Data_Types.pdf

      In conversation about 3 months ago permalink

      Attachments


    • Embed this notice
      Weekend Editor (weekend_editor@mathstodon.xyz)'s status on Tuesday, 18-Feb-2025 15:05:19 JST Weekend Editor Weekend Editor
      in reply to
      • Karsten Johansson
      • Alfred M. Szmidt
      • lispwizard

      @ksaj @lispwizard @amszmidt @screwtape

      There should be Special Compiler Warnings from Hell for people who do this.

      I mean, sure, compile their program. But not without some verbal abuse.

      In conversation about 3 months ago permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.