Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Parsing boards

Name: Anonymous 2009-10-09 9:56


(defun thread-info (line)
  (remove-if (lambda (x)         
               (zerop (length x)))      
             (cl-ppcre:split "<>" line)))
                                                                                         
; name author id post-count last-post                                                                                                                                                
(defmacro with-thread ((&rest names) line &body body)
  `(destructuring-bind `,(,@names &rest ,(gensym))
       (thread-info ,line)
     ,@body))
                                         
(defun thread-link (id &key (server "dis")
                    (board "prog")  
                    (post-number ""))
  (concatenate 'string                           
               "http://" server ".4chan.org/read/"
               board "/" (write-to-string id) "/"
               (if (stringp post-number)
                   post-number                    
                   (write-to-string post-number))))


Example use:

CL-USER> (with-open-file (s "data")                                                                                                                                           
           (do ((line (read-line s nil nil)                                                                                                                                          
                      (read-line s nil nil))                                                                                                                                         
                (i 0 (1+ i)))                                                                                                                                                        
               ((or (= i 10) (null line)))                                                                                                                                           
             (with-thread (name author id)                                                                                                                                           
                 line                                                                                                                                                                
                 (format t "Topic name: ~A. Author: ~A. Link: ~A~%"                                                                                                                  
                         name author (thread-link id)))))
                                                                                                                                             
Topic name: Have You Listened to Your Program Today?. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255036130"/                                                          
Topic name: JS. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255087731"/                                                                                                
Topic name: Sexual acts. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255078786"/                                                                                       
Topic name: Final Fantasy. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255014637"/                                                                                     
Topic name: Japan. Author: PROG. LANG. LISTS MEME FAN. Link: http://dis.4chan.org/read/prog/"1255075749"/                                                                            
Topic name: I'm just going to come out say it.. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1238918305"/                                                           
Topic name: Oh the personality. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255034599"/                                                                                
Topic name: Sussman attains enlightenment. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1209943333"/                                                                     
Topic name: Fall dog bombs the moon. Author: Anonymous. Link: http://dis.4chan.org/read/prog/"1255070515"/                                                                           
Topic name: Present day.... Author: Present time.... Link: http://dis.4chan.org/read/prog/"1254664796"/


P.S. My programming language > yours, suave style.

Name: Anonymous 2009-10-09 10:42

>>3
I find it hilarious when someone only sees parens in Lisp, but it's the natural thing for most people completly new to it to notice.
Lispers read code most of the code by indentation. I don't think it takes more than a few days to get used to it: it took me less than a week, while I read and wrote Lisp code. Nowadays, I'm very glad Lisp's syntax is made of lists: this makes so many things so much easier: macros, symbolic processing, writing your own interpreters, structured editing are all a breeze.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List