arclanguage / anarki

Community-managed fork of the Arc dialect of Lisp; for commit privileges submit a pull request.
http://arclanguage.github.io
Other
1.17k stars 160 forks source link

Pretty-print REPL values #142

Closed shawwn closed 5 years ago

shawwn commented 5 years ago

Tables:

arc> (load-table "../laarc/arc/news/profile/shawn")
'#hash((created . 1544527699)
       (email . "shawnpresser@gmail.com")
       (showdead . t)
       (name . "")
       (minaway . 180)
       (avg . 79/41)
       (karma . 99)
       (submitted
        .
        (563
         558
         550
         ...etc...
         3
         2
         1))
       (votes
        .
        ((1547783993 570 "nickpsecurity" nil up)
         (1547783117 577 "miles" "michaelhorowitz.com" up)
         (1547781958 576 "modern_einstein" nil up)
         (1547738512 564 "rain1" nil up)
         ...etc...
         (1547724648 568 "akkartik" "akkartik.name" up)
         (1546826046 422 "ers35" "tinyapps.org" up)
         (1546744550 398 "emily" "stanford.edu" up)))
       (verified . "shawnpresser@gmail.com")
       (delay . 0)
       (maxvisit . 20)
       (notify . t)
       (auth . 0)
       (id . "shawn")
       (about . "Bug fixer.<p>shawnpresser@gmail.com")
       (weight . 0.5))

Code:

arc> (readfile "../laarc/news.arc")
'((declare 'atstrings t)
  (load "firebase.arc")
  (=
   site-name*
   "laarc"
   site-abbrev*
   "LN"
   site-email*
   "hi@@laarc.io"
   site-twitter*
   "theshawwn"
   site-discord*
   "shawwn#3694"
   discord-url*
   "https://discord.gg/qaqkc9z"
   ...etc...)
  ...etc...
  (def
   chess-page
   (user (o from) (o to) (o board chess-board*))
   (longpage
    user
    (now)
    nil
    "chess"
    "Chess"
    "chess"
    (center (chess-board user from to board))))
  (def chess-at (x y) (+ (* (- y 1) 9) (- x 1)))
  (newsop
   chess
   (from to)
   (when (and (~blank from) (~blank to))
     (let ((a b) (x y))
       (map (%brackets map int (tokens _ #\,)) (list from to))
       (swap (chess-board* (chess-at x y)) (chess-board* (chess-at a b)))
       (wipe (lncache* "chess")))
     (wipe from)
     (wipe to))
   (if (blank from) (wipe to))
   (chess-page user from to))
  run-news)
akkartik commented 5 years ago

Great idea!