Search found 166 matches

by pjstirling
Mon Oct 23, 2017 4:26 pm
Forum: Common Lisp
Topic: Parsing a string.
Replies: 3
Views: 9988

Re: Parsing a string.

READ is used by the common-lisp reader for reading code, so it produces results following the rules of common-lisp syntax. If your file format used (double-)quoted strings then you would get what you wanted, but if your format is fixed by something else then you will need to use a different approach...
by pjstirling
Thu Oct 05, 2017 6:03 pm
Forum: Common Lisp
Topic: Pick and remove
Replies: 6
Views: 17256

Re: Pick and remove

While it's true that you'll be walking the list either way, consing up a new list doesn't make a lot of sense :) You care about the remainder list because you will be puilling more values out of it (otherwise you'd just use NTH) If you try to pick a sub-list of 100 items from a list of 5000 items th...
by pjstirling
Wed Oct 04, 2017 10:26 am
Forum: Common Lisp
Topic: Pick and remove
Replies: 6
Views: 17256

Re: Pick and remove

I don't think there's an elegant solution to this problem, but I had to write a version that doesn't walk the list twice for code that grabs a random selection from a list in the thousands. (defun pop-nth-helper (n previous) (unless (< 0 n) (error "pop-nth-helper only works for 0 < n")) (d...
by pjstirling
Sat Sep 16, 2017 9:37 am
Forum: Common Lisp
Topic: clisp -on-error abort
Replies: 4
Views: 11966

Re: clisp -on-error abort

The clisp documentation page you linked tells you how to do it: Function EXT:SET-GLOBAL-HANDLER. The function (EXT:SET-GLOBAL-HANDLER condition handler) establishes a global handler for the condition. The handler should be FUNCALLable (a SYMBOL or a FUNCTION). If it returns, the next applicable hand...
by pjstirling
Fri Sep 15, 2017 10:05 am
Forum: Common Lisp
Topic: clisp -on-error abort
Replies: 4
Views: 11966

Re: clisp -on-error abort

As an example here is the script I use to connect a terminal to emacs on another machine

Code: Select all

#!/bin/sh
ssh -t $1 emacsclient -nw
(I named it emacsc for quick access)
by pjstirling
Fri Sep 15, 2017 9:58 am
Forum: Common Lisp
Topic: clisp -on-error abort
Replies: 4
Views: 11966

Re: clisp -on-error abort

EXT:ABORT-ON-ERROR and EXT:EXIT-ON-ERROR are not what you want, probably. They act as PROGNs that execute a particular RESTART when code SIGNALs at runtime. So if you have a buffer with code, then if you wrap all of it with an EXT:EXIT-ON-ERROR then clisp will exit if something goes wrong. They don'...
by pjstirling
Sat Jun 24, 2017 4:06 am
Forum: Common Lisp
Topic: Assesing set-macro-character+deftype vs CLOS...
Replies: 5
Views: 16089

Re: Assesing set-macro-character+deftype vs CLOS...

It *is* possible to have lists print differently. You can do all sorts of weird things with the pretty printer[1] If you go this way make sure you use a copy of the pprint dispatch table, because the global one is used for printing things like macroexpansions. Depending on what you want to do it may...
by pjstirling
Sat Jun 03, 2017 10:35 am
Forum: Common Lisp
Topic: listp
Replies: 1
Views: 7080

Re: listp

IF is a SPECIAL-OPERATOR, it evaluates its first child for being non-NIL, if that's the case then it evaluates its second child and returns that as its result, or else it evaluates its third child and returns that. (LISTP 1) evaluates to NIL, because 1 is not a CONS, so it evaluates (+ 3 4) + is the...
by pjstirling
Fri Jan 20, 2017 4:03 pm
Forum: Common Lisp
Topic: Output truncated
Replies: 4
Views: 12172

Re: Output truncated

Presumably allegro has an init file, but I've never used allegro so I cant tell you what it is.

Generally speaking you don't want to globally make changes to the pretty-printer variables, you should temporarily bind them with LET to the values you want for the print call in question.
by pjstirling
Thu Jan 19, 2017 3:30 am
Forum: Common Lisp
Topic: Output truncated
Replies: 4
Views: 12172

Re: Output truncated

You probably want *print-readably*, but if you only care about avoiding the truncation you can bind *print-lines*, and *print-level* and *print-length*.

If you are using FORMAT then you will also want to use ~w instead of ~a