Zuo

1 program Added 2026-02-27T12:00:00Z Agent: claude-codeModel: claude-opus-4-6WebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit ab4491ddf2 · authored 2026-02-27T07:33:16+01:00 · agent claude-code · model claude-opus-4-6

Sources mentioning this language

2 sources · pl_id: pl/zuo
LLM (this repo) · 1Pldb

LLM-contributed programs

Directory Tree Viewer

Provenance: commit ab4491ddf2 · authored 2026-02-27T07:33:16+01:00 · agent claude-code · model claude-opus-4-6 · WebSearch enabled
code.zuo · license: MIT · added: 2026-02-27T12:00:00Z
#lang zuo

;; This module implements a simple version of the `tree` program,
;; which shows the content of a directory in tree form.

;; Another script could use this `tree` function...
(provide tree)

;; ... but if this script is the main one passed to Zuo,
;; then the `main` submodule is run, which parses command-line
;; arguments and call `tree`.
(module+ main
  ;; Imitates Racket's `command-line` form, but we have to explicitly
  ;; thread through `accum`, because there's no state
  (command-line
   :init (hash) ; initial accumulator (but `(hash)` is the default, anyway)
   :once-each
   ;; Each flag clause starts with the accumulator id
   [accum ("-a") "Include names that start with `.`"
          (hash-set accum 'all? #t)]
   [accum ("-h") "Show file sizes human-readable"
          (hash-set accum 'h-size? #t)]
   :args ([dir "."])
   (lambda (accum) ; args handler as procedure to receive the accumulator
     (if (directory-exists? dir)
         (tree dir
               (hash-ref accum 'all? #f)
               (hash-ref accum 'h-size? #f))
         (error (~a (hash-ref (runtime-env) 'script)
                    ": no such directory: "
                    dir))))))

;; Recur using `ls` to get a directory's content
(define (tree dir show-all? show-size?)
  (displayln dir)
  (let tree ([dir dir] [depth 0])
    (define elems (sort (ls dir) string<?))
    (let in-dir ([elems (if show-all? elems (filter not-dot? elems))])
      (unless (null? elems)
        (define elem (car elems))
        (define elem-path (build-path dir elem))
        (define s (stat elem-path))

        (let loop ([depth depth])
          (unless (= depth 0)
            (display "│  ")
            (loop (- depth 1))))
        (if (null? (cdr elems))
            (display "└─ ")
            (display "├─ "))

        (when show-size?
          (display (~a "[" (human-readable (hash-ref s 'size)) "] ")))
        (displayln elem)

        (when (eq? (hash-ref s 'type) 'dir)
          (tree elem-path (+ depth 1)))
        (in-dir (cdr elems))))))

(define not-dot?
  (let ([dot? (glob->matcher ".*")])
    (lambda (s) (not (dot? s)))))

;; Arithmetic is not Zuo's strong suit, since it supports only
;; 64-bit signed integers
(define (human-readable n)
  (define (decimal n)
    (define d (quotient 1024 10))
    (define dec (quotient (+ (modulo n 1024) (quotient d 2)) d))
    (~a (quotient n (* 1024)) "." dec))
  (define s
    (cond
      [(< n 1024) (~a n)]
      [(< n (quotient (* 1024 1024) 10)) (~a (decimal n) "K")]
      [else (~a (decimal (quotient n 1024)) "M")]))
  (if (< (string-length s) 4)
      (~a (substring "    " (string-length s)) s)
      s))

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Zuo (mapped to pl/zuo). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Zuo/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← Zull ZX Spectrum BASIC →