PasteRack.org
Paste # 85690
2025-12-22 12:03:29

Fork as a new paste.

Paste viewed 299 times.


Embed:

  1. #lang racket
  2.  
  3. (define (count_symbols lst)
  4.   (cond
  5.     [(null? lst) 0]                         ; empty list  0
  6.     [(symbol? lst) 1]                       ; symbol  count 1
  7.     [(pair? lst)                           ; list  recurse
  8.      (+ (count_symbols (car lst))
  9.         (count_symbols (cdr lst)))]
  10.     [else 0]))                              ; everything else  0
  11. (count_symbols
  12.  '(A random (list containing some
  13.             (words (to exemplify a (nested)) structure))))

=>

11