Lol, Scheme
1
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?
2
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?
3
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.
4
Name:
Anonymous
2007-08-25 17:16
ID:uwxHYS0t
5
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)
6
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.
7
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")));"
8
Name:
Anonymous
2007-08-25 21:27
ID:IDLg2RtP
>>7
also, in before some madshit Perl guru.
9
Name:
Anonymous
2007-08-25 21:28
ID:IDLg2RtP
>>7
also, i didn't escape the quote marks
10
Name:
Anonymous
2007-08-25 21:28
ID:Heaven
11
Name:
Anonymous
2007-08-25 21:29
ID:Heaven
# perl -e "@(&*^FPF:D>>D@D:F@F~;"
12
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'
13
Name:
Anonymous
2007-08-25 23:11
ID:adOWEAMe
perl -e 'open(IN,"in.txt");open(OUT,"out.txt");while(<IN>){tr/></][//;print OUT $_}'
14
Name:
Anonymous
2007-08-26 3:48
ID:s9hNKO+N
>>12
Wouldn't it be easier to
tr '<>' '[]'<in.txt>out.txt
15
Name:
Anonymous
2007-08-26 10:41
ID:IyKcXuOL
16
Name:
Anonymous
2009-08-16 23:26
Lain.
17
Name:
Anonymous
2011-03-13 11:33
I remember making this thread.
18
Name:
Anonymous
2011-03-13 11:36
19
Name:
Anonymous
2011-03-14 1:29