Search found 10 matches

by karol.skocik
Sat Sep 04, 2010 12:40 pm
Forum: Common Lisp
Topic: File I/O woes
Replies: 9
Views: 7509

Re: File I/O woes

I usually make my life easier with iterate:

Code: Select all

(iter (for line :in-file "/home/md/.emacs" :using #'read-line)
    (print line))
by karol.skocik
Thu Jun 03, 2010 2:46 pm
Forum: Common Lisp
Topic: Redefining special operators
Replies: 3
Views: 3549

Re: Redefining special operators

sure you can, look here for example: http://github.com/ks/X.LET-STAR
this is how you make your defpackage:

(defpackage :your-lib
(:use :common-lisp :x.let-star ...)
(:shadowing-import-from x.let-star let*) ;; the important line
...)
by karol.skocik
Tue Apr 13, 2010 4:43 am
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32376

Re: What little functions/macros do you use?

But what is the Dynamic-extent for? From what i read, it declares the variables value not usable outside the body. I guess that would make a difference, but not sure if for those integers, i mean, they're copied when you pass them, right? Looking at the examples in clhs you are not supposed to do w...
by karol.skocik
Mon Apr 12, 2010 1:23 am
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32376

Re: What little functions/macros do you use?

I guess this one is also useful sometimes: Beware - it uses my let-star library. To remove dependency - replace `(let* ((,dim-syms (array-dimensions ,matrix))) with `(destructuring-bind (,dim-syms) (array-dimensions ,matrix) ....) (defmacro do-matrix-indices (indices matrix &body body) (let ((in...
by karol.skocik
Mon Apr 05, 2010 1:28 am
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32376

Re: What little functions/macros do you use?

Hmm, never really needed the previous of the last of the list. Counting is a nice touch, but i do prefer give things one purpose, of course you could do: (collecting (:onto your-list) (let ((cnt 0) (before-last (last your-list 2))) (flet ((collecting (element) (setq cnt (+ cnt 1) before-last (or (c...
by karol.skocik
Sat Apr 03, 2010 10:54 am
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32376

Re: What little functions/macros do you use?

gugamilare wrote:
karol.skocik wrote:

Code: Select all

(defun before-last (list)
  (if (cddr list)
      (before-last (cdr list))
      list))
You can use (last list 2) instead:

Code: Select all

CL-USER> (last '(1 2 3 4 5 6) 2)
(5 6)
Thanks! Didn't know that.
Karol
by karol.skocik
Sat Apr 03, 2010 12:38 am
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32376

Re: What little functions/macros do you use?

I sometimes use a handy macro which allows me to construct lists in order (without need to be reversed). Also, it has a nice feature - keeps size of the list - no need to #'length at the end when you need it. And the best features at the end - it gives you a hand on last and previous to last element...
by karol.skocik
Tue Nov 17, 2009 2:05 am
Forum: Common Lisp
Topic: Must Know Libs
Replies: 5
Views: 7021

Re: Must Know Libs

grault wrote:... I'd suggest metabang-bind ....
Use http://github.com/ks/X.LET-STAR instead of bind, it's user extensible and nicer 8-)

Karol
by karol.skocik
Fri Nov 13, 2009 10:53 am
Forum: Common Lisp
Topic: Must Know Libs
Replies: 5
Views: 7021

Re: Must Know Libs

I would say, there is a chance sooner or later you will need: http://www.cliki.net/CXML on CXML page are also other very useful libraries for handling xml validation and xpath library. Also, everything from Edi Weitz is worth recommending: http://weitz.de/ For DB stuff, you may appreciate http://com...
by karol.skocik
Tue Sep 22, 2009 4:53 pm
Forum: Common Lisp
Topic: Better then loop/iterate?
Replies: 41
Views: 60122

Re: Better then loop/iterate?

I have been a little annoyed by this: Having flets, lets, macrolets and symbol-macrolets separate all the time has disadvantages. 1) More nested then need be, implying more parenthesis, more depth of indentation. 2) Sometimes need lets or flets in some specific order, causing more nesting. So it mi...