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

Pages: 1-4041-

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:15

P.S. My programming language > yours, suave style.
That is what lispniks actually believe.

Name: Anonymous 2009-10-09 10:27

i tried to read it, but all i see is (((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))(((((unfun))))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()((((x)))))))))((((()))))))()())(y)))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()((((myeyesarebeingraped)))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))()()()))))))()(((()))))))))((((()))))))()())()))))))))(((()()((())))()(())())))()(())))()))))))((()()()()()()))((((())))))))))))))(defun)()()))))))()(((()))))))))((((()))))))()())()))))))))

Name: Anonymous 2009-10-09 10:28

>>1
Nice, WITH-THREAD is pretty suave indeed, but doesn't your implementation warn you, if you don't add a IGNORE declaration on that gensym?

Someone out to make a /prog/scrape in CL if they're bored enough.

As for parsing, I have to implement a META-like parser myself which works on S-Exps(not like there aren't a bunch already floating around, but it doesn't look very hard to do anyway):
http://home.pipeline.com/~hbaker1/Prag-Parse.html

Name: Anonymous 2009-10-09 10:34

>>1
Looks like your'e programming language can't strip off trailing spaces.

Name: Anonymous 2009-10-09 10:42

>>4
but doesn't your implementation warn you, if you don't add a IGNORE declaration on that gensym?
Why would you let an implementation bloat your code?
>>5
He's probably using SLIME, the trailing whitespace is a fuckup of SLIME (or rather, his fuckup way of copying text). An actual error in his code is that id is a string and (write-to-string id) should be replaced simply by 'id' (and then the links won't be broken).

Glad to see some lisp code now and then, reminds me this is a board about programming.

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.

Name: Anonymous 2009-10-09 10:46

>>6
You can supress the warning, but I thought it's considered good style to mark variables which are meant to be ignored accordingly, but then there's as many Lisp styles as there's Lispers. The closest I can think of any written guidelines are Norvig's: http://www.cs.umd.edu/~nau/cmsc421/norvig-lisp-style.pdf

Name: Anonymous 2009-10-09 10:48

>>7
LISP = Python?  I think I can understand Abelson.

Name: Anonymous 2009-10-09 10:50

>>9
The difference is that indentation in lisp aids in readability, while indentation in python gets in the way.

Name: Anonymous 2009-10-09 10:51

>>9
You read it by indentation, but the indentation isn't forced in any way: there's many ways to format your code, of course you should use your own judgement about where it would be better to break a line. The parens give the code the structure. Of course the parens are just a way to delimit lists, they're gone after READ, and your code simply becomes a list/tree or if you want a more fancy term, the code you write is an AST.

Name: Anonymous 2009-10-09 10:55

>>11
It can be represented as an AST but it's just S-exps, memo 3 RECURSIVE FUNCTIONS OF SYMBOLIC EXPRESSIONS AND THEIR
              COMPUTATION BY MACHINE

Name: Anonymous 2009-10-09 11:25

LOLisp

Name: Anonymous 2009-10-09 11:35

Or you could, you know, just parse the subject.txt like /prog/scrape does

Name: Anonymous 2009-10-09 11:38

>>14 what do you mean?

Name: PHPAdvocate !/IpofbrXAc 2009-10-09 13:44


$prog_index = file_get_contents('http://dis.4chan.org/prog/');

preg_match_all("%a name='([0-9]+)%", $prog_index, $ids);
preg_match_all('%postername">(.+?)<%', $prog_index, $authors);
preg_match_all("%1-40'>(.+?)</a></h2>%", $prog_index, $titles);

foreach($ids[1] as $key => $id)
{
    $thread_data[$id] = array
    (
        'author' => strip_tags( $authors[1][$key] ),
        'title'  => $titles[1][$key]
    );
}

foreach($thread_data as $id => $data)
{
    printf('Topic name: %s. Author: %s. Link: http://dis.4chan.org/read/prog/%d' . "\n", $data['title'], $data['author'], $id);
}


Topic name: Haxus the Original Poster. Author: Haxus the Original Poster. Link: http://dis.4chan.org/read/prog/1252033912
Topic name: Final Fantasy. Author: Haxus the haxer. Link: http://dis.4chan.org/read/prog/1255014637
Topic name: Twitter accounts. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1254239526
Topic name: Coolness. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1255015277
Topic name: Parsing boards. Author: Haxus the gay. Link: http://dis.4chan.org/read/prog/1255096595
Topic name: The Forced Writing of Code. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1255101445
Topic name: JS. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1255087731
Topic name: A message to  Linux fans. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1252430981
Topic name: Have You Listened to Your Program Today?. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1255036130
Topic name: THE RAPE TUNNEL. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1254809827
Topic name: Jon Harrop. Author: Anonymous. Link: http://dis.4chan.org/read/prog/1255009907
Topic name: Sexual acts. Author: Haxus the lvl.99 black mage. Link: http://dis.4chan.org/read/prog/1255078786
Topic name: Japan. Author: Anonymous. 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: Haxus the twat. 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: Haxus the leaver. Link: http://dis.4chan.org/read/prog/1254664796

Name: PHPAdvocate !/IpofbrXAc 2009-10-09 13:50

>>1
32 lines.

>>16
12 lines.

That's a difference of 20 lines. My code is 63% more efficient.

Name: Anonymous 2009-10-09 14:02

>>17
Topic name: Parsing boards. Author: Haxus the gay. Link: http://dis.4chan.org/read/prog/1255096595

Actually this thread was made by anonymous so your program fails hard if that's the output. Plus it doesn't do what >>1 does and IHBT for replying.

Name: Anonymous 2009-10-09 14:03

>>17
Could probably be done in like 5 lines of Perl.

Name: Anonymous 2009-10-09 14:05

>>19
What? I though newlines crashed the perl interpreter

Name: Anonymous 2009-10-09 14:10

>>20
fuck, I lold.

Name: Anonymous 2009-10-09 18:52

>>19
Some people, when confronted with a problem, think "I know, I'll use Perl!" Now they have three problems and several sleepless nights.

Name: Anonymous 2009-10-09 18:57

Some people, when confronted with a problem, think "I know, I'll ask /prog/!"

Name: Anonymous 2009-10-09 19:03

Some people, when confronted with a problem, think "which spell should I cast to solve it?"

Name: Anonymous 2009-10-10 1:50

>>21
this

Name: Anonymous 2009-10-10 1:52

Some people, when confronted with a problem, think "I know, I'll create a GUI in Visual Basic!"

Name: Anonymous 2009-10-10 2:00

>>26
PROBLEM SOLVED

Name: Anonymous 2009-10-10 3:15

>>26

Now you've got to traceroot their internet protocol.

Name: Anonymous 2009-10-10 4:07

Some people, when confronted with a problem, think "Have I read my SICP today?

Name: Anonymous 2009-10-10 4:11

Some people, when confronted with a problem, ask themselves "Am I feeling lucky... uhh... punk?"

Name: Anonymous 2009-10-10 4:16

Some people, when confronted with a problem, think of possible solutions.

Name: Anonymous 2009-10-10 4:18

>>31
Some people, when confronted with a problem, come up with a solution. Now they have no problems.

Name: Anonymous 2009-10-10 4:25

Some people, when confronted with a problem, think to use Lisp as their solution. Now they have two problems.

Name: Anonymous 2009-10-10 5:06

Some mathematicians, when confronted with a problem, think of 2 solutions.  Now they have -1 problems.

Name: Anonymous 2009-10-10 5:22

Some managers, when confronted with a problem, delegate the problem. Now they have no problems.

Name: Anonymous 2009-10-10 5:28

Some people, when confronted with a problem, have not yet solved the previous problem. Now they have two problems.

Name: Anonymous 2009-10-10 5:45

Some anii, when confronted with a problem, end up being haxed. Now they have two problems.

Name: Anonymous 2009-10-10 7:13

Some people, when confronted with a problem, give up and fap to some loli porn. Now they have commited a crime.

Name: yuyuyuuuuuu 2009-10-10 8:58

[iurl=http://www.youtube.com]http://www.youtube.com[/irl]

Name: Anonymous 2009-10-10 9:00

[iurl=http://www.youtube.com]http://www.youtube.com[/iurl]

Name: Anonymous 2009-10-10 9:00

[url=http://www.youtube.com]http://www.youtube.com[/url]

Name: Anonymous 2009-10-10 9:01

>>39-41
ಠ_ಠ get out

Name: Anonymous 2011-10-26 7:44

    test

Name: Anonymous 2011-10-26 15:59

Lisp
GC is shit.

Name: Anonymous 2011-10-26 16:01

>>44
fuck off and die, fag

Name: Anonymous 2011-10-26 23:09

Some anii, when confronted with a problem, end up engulfing the haxor. Now the anii and the haxors each have one problem.

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