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

Pages: 1-

Lol, Scheme

Name: Anonymous 2007-08-25 16:45 ID:132hQDyN

(define i (open-input-file "in.txt"))
(define o (open-output-file "out.txt"))
(define (bbc)
  (if (eof-object? (peek-char i))
      (begin (newline o) (close-output-port o))
      (case (peek-char i)
        ((#\<) (display #\[ o) (bbc))
        ((#\>) (display #\] o) (bbc))
        (else (display (read-char i) o)))))


This is supposed to be an EXPERT BBCODE UTILITY to convert HTML tags to BBCode, but when I run it, it never stops. I am only a beginner, but I've analysed it and noticed no errors. A little help here?

Name: Anonymous 2007-08-25 16:47 ID:rjVmhuj4

I'm not familiar with Scheme at all, but it looks like you're not advancing the file pointer at all?

Name: Anonymous 2007-08-25 17:07 ID:4JGQH/7m

Second peek-char should be read-char, you FAILTOAD.  Never approach Scheme unless you fully understand SICP.

Name: Anonymous 2007-08-25 17:16 ID:uwxHYS0t

wut?
see >>2

Name: Anonymous 2007-08-25 18:05 ID:adOWEAMe

(with-input-from-file "in.txt"
 (lambda ()
  (with-output-to-file "out.txt"
   (lambda ()
    (let loop ((c (read-char)))
     (if (eof-object? c)
         (newline)
         (begin
          (display (case c
           (#\< #[)
           (#\> #\])
           (else c)))
          (loop (read-char)))))))))


(define (bbc)
 (let loop ((c (read-char)))
   (if (eof-object? c)

Name: Anonymous 2007-08-25 18:19 ID:rQ1sZ/O9

but when I run it, it never stops
Don't worry, that just means its touring complete.

Name: Anonymous 2007-08-25 21:25 ID:IDLg2RtP

$ php -r "file_put_contents("out.txt",str_replace(array("<",">"),array("[","]"),file_get_contents("in.txt")));"

Name: Anonymous 2007-08-25 21:27 ID:IDLg2RtP

>>7
also, in before some madshit Perl guru.

Name: Anonymous 2007-08-25 21:28 ID:IDLg2RtP

>>7
also, i didn't escape the quote marks

Name: Anonymous 2007-08-25 21:28 ID:Heaven

>>7
You made kitty cry

Name: Anonymous 2007-08-25 21:29 ID:Heaven

# perl -e "@(&*^FPF:D>>D@D:F@F~;"

Name: Anonymous 2007-08-25 23:10 ID:adOWEAMe

you don't even need perl

cat in.txt | tr '<>' '[]' > out.txt

cat in.txt | perl -nle 'tr/></][/;print'

Name: Anonymous 2007-08-25 23:11 ID:adOWEAMe

perl -e 'open(IN,"in.txt");open(OUT,"out.txt");while(<IN>){tr/></][//;print OUT $_}'

Name: Anonymous 2007-08-26 3:48 ID:s9hNKO+N

>>12
Wouldn't it be easier to tr '<>' '[]'<in.txt>out.txt

Name: Anonymous 2007-08-26 10:41 ID:IyKcXuOL

>>14
no.

Name: Anonymous 2009-08-16 23:26

Lain.

Name: Anonymous 2011-03-13 11:33

I remember making this thread.

Name: Anonymous 2011-03-13 11:36

>>17
So?

Name: Anonymous 2011-03-14 1:29

>>17
FAILTOAD

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