BBcode practise grounds
1
Name:
Anonymous
2007-06-17 16:46
ID:zJT0c10Q
(define(eval exp env)(cond((self-evaluating? exp) exp)((variable? exp)(lookup-variable-value exp env))((quoted? exp)(text-of-quotation exp))((assignment? exp)(eval-assignment exp env))((definition? exp)(eval-definition exp env))((if? exp)(eval-if exp env))((lambda? exp)(make-procedure(lambda-parameters exp)(lambda-body exp)
env))((begin? exp)(eval-sequence(begin-actions exp) env))((cond? exp)(eval(cond->if exp) env))((application? exp)(apply(eval(operator exp) env)(list-of-values(operands exp) env)))(else(error "Unknown expression type - EVAL" exp))))
2
Name:
Anonymous
2007-06-17 16:47
ID:zJT0c10Q
(define(eval exp env)(cond((self-evaluating? exp) exp)((variable? exp)(lookup-variable-value exp env))((quoted? exp)(text-of-quotation exp))((assignment? exp)(eval-assignment exp env))((definition? exp)(eval-definition exp env))((if? exp)(eval-if exp env))((lambda? exp)(make-procedure(lambda-parameters exp)(lambda-body exp) env))((begin? exp)(eval-sequence(begin-actions exp) env))((cond? exp)(eval(cond->if exp) env))((application? exp)(apply(eval(operator exp) env)(list-of-values(operands exp) env)))(else(error "Unknown expression type - EVAL" exp))))
3
Name:
Anonymous
2007-06-17 16:50
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
4
Name:
Anonymous
2007-06-17 16:50
ID:zJT0c10Q
(define test(lambda (foo) 'see-if-this-works)))
5
Name:
Anonymous
2007-06-17 16:51
ID:Heaven
ONE WORD, FORCED STRIPPAGE OF WHITESPACE, THREAD OVER
6
Name:
Anonymous
2007-06-17 16:52
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
7
Name:
Anonymous
2007-06-17 16:53
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
8
Name:
Anonymous
2007-06-17 16:53
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
9
Name:
Anonymous
2007-06-17 16:55
ID:zJT0c10Q
(define test
(lambda(foo) 'see-if-this-works)))
10
Name:
Anonymous
2007-06-17 16:55
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
11
Name:
Anonymous
2007-06-17 16:57
ID:zJT0c10Q
THIS GOES UNDER THE BBCODE PUBLIC LISCENCE
[m][code](define test
(lambda (foo) 'see-if-this-works)))[/m] [/code]
12
Name:
Anonymous
2007-06-17 16:57
ID:zJT0c10Q
>>11
uhh how 2 open source bbcode?
13
Name:
Anonymous
2007-06-17 16:57
ID:Heaven
i suck
14
Name:
Anonymous
2007-06-17 16:58
ID:zJT0c10Q
(define test
(lambda (foo) 'see-if-this-works)))
15
Name:
Anonymous
2007-06-17 17:41
ID:zJT0c10Q
(F X)
16
Name:
Anonymous
2007-06-17 17:48
ID:f5Fd5wwd
a => [a]test[/a]
b => test
c => [c]test[/c]
d => [d]test[/d]
e => [e]test[/e]
f => [f]test[/f]
g => [g]test[/g]
h => [h]test[/h]
i => test
j => [j]test[/j]
k => [k]test[/k]
l => [l]test[/l]
m => test
n => [n]test[/n]
o => test
p => [p]test[/p]
q => [q]test[/q]
r => [r]test[/r]
s => test
t => [t]test[/t]
u => test
v => [v]test[/v]
w => [w]test[/w]
x => [x]test[/x]
y => [y]test[/y]
z => [z]test[/z]
17
Name:
Anonymous
2007-06-17 17:56
ID:zJT0c10Q
18
Name:
Anonymous
2007-06-17 18:02
ID:zJT0c10Q
(DEFINE TEST ( LAMBDA ( FOO ) ( QUOTE SEE-IF-THIS-WORKS ) ) )
19
Name:
Anonymous
2007-06-17 18:04
ID:Heaven
(DEFINE TEST ( LAMBDA ( FOO[spoiler] ) ( QUOTE SEE-IF-THIS-WORKS ) ) )
20
Name:
Anonymous
2007-06-17 18:08
ID:zJT0c10Q
(DEFINE TEST(LAMBDA(FOO)(QUOTE SEE-IF-THIS-WORKS)))
21
Name:
Anonymous
2007-06-17 18:08
ID:zJT0c10Q
>>19
lol .... I did notice
thanks
22
Name:
Anonymous
2007-06-17 18:11
ID:z4/dw3+d
23
Name:
Anonymous
2007-06-17 18:20
ID:zJT0c10Q
(DEFINE TEST (LAMBDA (FOO) (QUOTE SEE-IF-THIS-WORKS)))
24
Name:
Anonymous
2007-06-17 18:23
ID:zJT0c10Q
now with italix
(define test (lambda (foo) (quote see-if-this-works)))
25
Name:
Anonymous
2007-06-17 18:40
ID:zJT0c10Q
(defun ouroboros (element &aux (ouroboros (cons element nil))) (setf (cdr ouroboros) ouroboros) ouroboros)
26
Name:
Anonymous
2007-06-17 18:41
ID:zJT0c10Q
(defun ouroboros (element &aux (ouroboros (cons element nil)))
(setf (cdr ouroboros) ouroboros) ouroboros)
ALMOST FININSHED ILL REPLEACS THIS PROGRAM SOON
27
Name:
Anonymous
2007-06-17 18:57
ID:zJT0c10Q
(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
28
Name:
Anonymous
2007-06-17 19:09
ID:zJT0c10Q
(define eval (lambda (exp env) (cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "unknown expression type - eval" exp)))))
29
Name:
Anonymous
2007-06-17 19:14
ID:zJT0c10Q
30
Name:
Anonymous
2007-06-17 19:16
ID:zJT0c10Q
(define eval (lambda (exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp)
env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "unknown expression type - eval" exp)))))
31
Name:
Anonymous
2007-06-17 19:24
ID:zJT0c10Q
(define eval (lambda (exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp)
env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "unknown expression type - eval" exp)))))
32
Name:
Anonymous
2007-06-17 19:26
ID:zJT0c10Q
(a b
c)
(a b
c)
33
Name:
Anonymous
2007-06-17 19:26
ID:zJT0c10Q
(a b
c)
34
Name:
Anonymous
2007-06-17 19:27
ID:zJT0c10Q
(a b
c)
35
Name:
Anonymous
2007-06-17 19:33
ID:f5Fd5wwd
COMBO BREAKER!
36
Name:
Anonymous
2007-06-17 19:36
ID:Heaven
(define eval (lambda (exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp)
env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (eval (cond->if exp) env)) ((application? exp) (apply (eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "unknown expression type - eval" exp)))))
37
Name:
Anonymous
2007-06-17 19:37
ID:zJT0c10Q
(a b
c)
38
Name:
Anonymous
2007-06-17 19:38
ID:zJT0c10Q
(define factorial (lambda (n) (if (= n 0) 1 (* n (factorial (- n 1))))))
39
Name:
Anonymous
2007-06-17 19:39
ID:zJT0c10Q
(define factorial (lambda (n) (if (= n 0) 1 (* n (factorial (- n 1))))))
40
Name:
Anonymous
2007-06-17 19:41
ID:zJT0c10Q
(a b
c d)
(a (b)
c (d))
(a (b
c)
d)
41
Name:
Anonymous
2007-06-17 19:42
ID:zJT0c10Q
(a (b
c (d e f)
g
h))
42
Name:
Anonymous
2007-06-17 19:44
ID:zJT0c10Q
(a (b
c
(d e f)
g
h))
43
Name:
Anonymous
2007-06-17 19:58
ID:zJT0c10Q
(a (b
c
(d e f)
g
h))
44
Name:
Anonymous
2007-06-17 20:13
ID:zJT0c10Q
(define factorial
(lambda(n)
(if(= n 0) 1
(* n(factorial(- n 1))))))
45
Name:
Anonymous
2007-06-17 20:17
ID:zJT0c10Q
(define factorial
(lambda (n)
(if (= n 0) 1
(* n (factorial (- n 1))))))
46
Name:
Anonymous
2007-06-17 20:17
ID:zJT0c10Q
(define eval
(lambda (exp env)
(cond ((self-evaluating? exp) exp)
((variable? exp) (lookup-variable-value exp env))
((quoted? exp) (text-of-quotation exp))
((assignment? exp) (eval-assignment exp env))
((definition? exp) (eval-definition exp env))
((if? exp) (eval-if exp env))
((lambda? exp)
(make-procedure (lambda-parameters exp)
(lambda-body exp)
env))
((begin? exp)
(eval-sequence (begin-actions exp) env))
((cond? exp) (eval (cond->if exp) env))
((application? exp)
(apply (eval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "unknown expression type - eval" exp)))))
47
Name:
Anonymous
2007-06-17 20:21
ID:zJT0c10Q
(defun ouroboros (element &aux (ouroboros (cons element nil)))
(setf (cdr ouroboros) ouroboros) ouroboros)
(a (b
c
(d e f)
g
h))
48
Name:
Anonymous
2007-06-17 20:26
ID:zJT0c10Q
(defun ouroboros (element &aux (ouroboros (cons element nil)))
(setf (cdr ouroboros) ouroboros) ouroboros)
(defun insert (element list) (butlast (mapcan (function list) list (ouroboros element))))
(defparameter *paren-prolog* (quote (:/code :b :code "(" :/code :/b :code)))
(defparameter *paren-epilog* (quote (:/code :b :code ")" :/code :/b :code)))
(defparameter *special-newline-value* (cons nil nil))
(defparameter *special-indent-value* (cons nil nil))
(defparameter *lisp-keywords* (quote (block let* return-from catch load-time-value setq eval-when locally symbol-macrolet flet macrolet tagbody function multiple-value-call the go multiple-value-prog1 throw if progn unwind-protect labels progv let quote)))
49
Name:
Anonymous
2007-06-17 20:29
ID:zJT0c10Q
(defun compile-lisp-to-bbcode (file) (bbcode-compile-toplevel (read-from-string (apply (function concatenate) (quote string) (preprocess-indentation (read-file-as-lines file))))))
(defun read-file-as-lines (file) (with-open-file (stream file) (loop for line = (read-line stream nil :eof) until (eq line :eof) collect line)))
(defun preprocess-indentation (list-of-lines)
(mapcar (lambda (line)
(let ((spaces
(or (mismatch line (make-string (length line) :initial-element #\)) 0)))
(concatenate (quote string)
(apply (function concatenate) (quote string)
(loop repeat spaces collect " #.*special-indent-value* "))
line
" #.*special-newline-value*")))
list-of-lines))
50
Name:
Anonymous
2007-06-17 20:31
ID:zJT0c10Q
(defun bbcode-compile-toplevel (expression)
(bbcode-generate-target-language
(bbcode-optimize
(bbcode-cleanup-whitespace
(append (list :m :code)
(bbcode-compile expression)
(list :/code :/m))
(quote (" " *special-indent-value* *special-newline-value*))))))
51
Name:
Anonymous
2007-06-17 20:32
ID:zJT0c10Q
(defun bbcode-compile (expression)
(cond ((not (consp expression))
(let ((name (string-downcase (format nil "~s" expression))))
(cond ((find expression *lisp-keywords*)
(list :/code :i :code name :/code :/i :code))
((or (eq expression *special-newline-value*)
(eq expression *special-indent-value*))
(list expression))
(t (list name)))))
((and (listp expression)
(listp (cdr expression)))
(append *paren-prolog*
(apply (function append)
(insert (list " ")
(mapcar (function bbcode-compile) expression)))
*paren-epilog*))
(t (append *paren-prolog*
(insert " "
(append (bbcode-compile (car expression))
(list ".")
(bbcode-compile (cdr expression))))
*paren-epilog*))))
52
Name:
Anonymous
2007-06-17 20:33
ID:zJT0c10Q
(defun bbcode-cleanup-whitespace (bbcode-ast whitespaces)
(let (change-made)
(labels ((cleanup-helper (bbcode-ast whitespace)
(cond ((< (length bbcode-ast) 2) bbcode-ast)
((and (equal (first bbcode-ast) whitespace)
(find (second bbcode-ast)
(quote (:code :/code :b))))
(setf change-made t)
(cleanup-helper
(list*
(second bbcode-ast) whitespace
(cddr bbcode-ast))
whitespace))
(t (cons (car bbcode-ast)
(cleanup-helper (cdr bbcode-ast) whitespace))))))
(loop do (setf change-made nil)
(loop for whitespace in whitespaces
do (setf bbcode-ast (cleanup-helper bbcode-ast whitespace)))
while change-made)
bbcode-ast)))
53
Name:
Anonymous
2007-06-17 20:35
ID:zJT0c10Q
(defun bbcode-generate-target-language (code)
(if (not (null code))
(progn
(bbcode-generate-target-language
(cond ((stringp (car code))
(format t "~a" (car code))
(cdr code))
((eq *special-newline-value* (car code))
(format t "~%")
(cdr code))
((eq *special-indent-value* (car code))
(format t " ")
(if (string= (cadr code) " ") (cddr code) (cdr code)))
(t (format t "[~a]" (symbol-name (car code)))
(cdr code)))))
(terpri)))
54
Name:
Anonymous
2007-06-17 20:36
ID:zJT0c10Q
ugh bbcode-optimize is too big to post, whatever
55
Name:
Anonymous
2007-06-18 2:44
ID:xAgf3Ta9
>>54
Perhaps you should rewrite it in a three-line Haskell program, then!
56
Name:
Anonymous
2007-06-18 6:06
ID:No128k/f
>>55
ill leave that to you mr epic faggot
57
Name:
Anonymous
2007-06-18 7:26
ID:xAgf3Ta9
>>56
Okay, what should the function do?
58
Name:
Anonymous
2007-06-18 7:33
ID:Heaven
>>57
be awesome and pwn your grandmother
59
Name:
Anonymous
2007-06-18 8:08
ID:UbxogPcV
>>57
given a filename read it in as a lisp expression and print it with optimized BBCode (bold parenthesis and italic language keywords) also with the line endings preserved.
60
Name:
Anonymous
2007-06-18 12:11
ID:xAgf3Ta9
>>59
What in the world does that have to do with optimization?
61
Name:
Anonymous
2007-06-18 12:55
ID:UbxogPcV
>>60
"
" → ""
and other more complex optimisations
62
Name:
Anonymous
2007-06-18 13:15
ID:xAgf3Ta9
>>61
"<code></code>" -> ""
i.e. remove empty tags? Doesn't sound like a good idea to me, BBcode programs can change their output if you remove empty tags.
63
Name:
Anonymous
2007-06-18 13:28
ID:UbxogPcV
>>62
dude I wrote this program and it works, I think I would know.
Also I have 8 years BBCode experience, so
don't fucking start
64
Name:
Anonymous
2007-06-18 13:40
ID:xAgf3Ta9
>>63
PLEASE DON'T ENCLOSE ME IN
S PO IL ER TAGS, O EXPERT BBCODE PROGRAMMER !!
65
Name:
Anonymous
2007-06-18 14:27
ID:UbxogPcV
>>64
yeah, cute trick.. I used to do that
years ago.
Now ive learned the true skill of
minimalist bbcode programming for maximum effect.
66
Name:
Anonymous
2007-06-18 20:54
ID:BhldS2tX
67
Name:
Anonymous
2007-06-19 14:42
ID:coifDlHt
>>55
ךםך
Typical haskell fag.. talks crap but dont WALK!
68
Name:
Anonymous
2007-06-19 15:43
ID:Jd+M8bw/
he swallowes i could know
69
Name:
Anonymous
2007-06-19 17:13
ID:31BmU9qc
>>67
EXPERT UNICODE PROGRAMMER
70
Name:
EXPERT BBCODE PROGRAMMER
2007-06-19 17:43
ID:8610UN40
[quote="Anonymous"]Also I have 8 years BBCode experience, so don't fucking start[/quote]
Well prove it. Oh guess what , you can't, because you're too much of a coward to tell us your name.
71
Name:
Anonymous
2007-06-19 17:56
ID:Heaven
>>70
His name is Robert Paulson.
72
Name:
Anonymous
2007-06-19 18:23
ID:WXKrPbZi
>>70
His name is Robert Paulson
73
Name:
Anonymous
2007-06-19 18:51
ID:ECnpj1gP
>>70
His name is Robert Paulson
74
Name:
Anonymous
2009-01-14 14:02
NO EXCEPTIONS
75
Name:
2010-09-10 4:34