OpenCOBOL embedding Guile, evaluating bf, and displaying DERP. In only 38 lines of COBOL. …
Well met,
I wrote this one up for a co-worker
$ guile
(use-modules (ice-9 eval-string))
(define derp "+++++ +++++ [ > +++++ ++ > +++++ +++ > + <<< - ] > -- . + . > ++ . -- . > .")
(eval-string derp #:lang 'brainfuck)
DERP
and
$ guile
(use-modules (ice-9 eval-string))
(define derp "+++++ +++++ [ > +++++ ++ > +++++ +++ > + <<< - ] > -- . + . > ++ . -- . > . > , [ <<< - . + . > ++ . -- . > . > - ]")
(eval-string derps #:lang 'brainfuck) *
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
He likes derps. So derps in COBOL too:
OCOBOL >>SOURCE FORMAT IS FIXED
*> ***************************************************************
*> Author: Brian Tiffin
*> Date: 20110720
*> Purpose: Demonstrate libguile bf interactions
*> Tectonics: cobc -x -lguile-2.0 derps.cob
*> ***************************************************************
identification division.
program-id. derps.
data division.
working-storage section.
77 derps pic x(124) value
"+++++ +++++ [ > +++++ ++ > +++++ +++ > + <<< - ] >" &
- " -- . + . > ++ . -- . > . > , [ <<< - . + . " &
- "> ++ . -- . > . > - ]".
77 scm-result usage pointer.
*> ***************************************************************
procedure division.
call "scm_init_guile" end-call
*> eval-string in bf context, res is unspecified
call "scm_c_eval_string"
using function concatenate(
"(use-modules (ice-9 eval-string))"
'(define derps "' derps '")'
"(eval-string derps #:lang 'brainfuck)"
low-value)
returning scm-result
on exception display function exception-location end-display
end-call
goback.
end program derps.
$ cobc -x derps.cob -lguile-2.0
$ ./derps
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
DERP
For the comma value I typed a tab (ascii 9)…in the first sample, * (ascii 42).
Useless, fun. derp
Cheers,
Brian