newLISP Database

Started by kinghajj, September 12, 2007, 04:32:04 PM

Previous topic - Next topic

kinghajj

I wrote this up quickly last night and this afternoon.



It's a database library written completely in newLISP. It's very simple, but I'll make it more capable in later releases. I wrote this because I didn't want to deal with SQL. I suppose I could have written a wrapper around the sqlite3 library for newLISP to hide the SQL from me, but that would have been less fun.



See the README file for general information, and the example.lsp file for example usage.



http://kinghajj.home.comcast.net/nldb.tar.bz2">//http://kinghajj.home.comcast.net/nldb.tar.bz2

cormullion

#1
Wow - really good stuff here! It makes sense to do a DB this way - anyway, sqlite3.lsp is also available if people want.



Have you checked out newlispdoc for your documentation needs? It makes generating a 'module' listing easy, anyway.



How about this for truncate:


(define (truncat lst size)
(let (len (length lst))
  (if (<= len size)
    (set 'lst (append lst (dup nil (- size len))))
    (set 'lst  (chop lst (-  len size))))
  lst
  )
)

kinghajj

#2
Wow, that is a much cleaner version of truncate! Here's a more concise version.



(define (truncate lst size)
  (let ((len (length lst)))
    (if (<= len size)
      (append lst (dup nil (- size len)))
      (chop lst (- len size)))))


I'll use this in the next release. Thanks.

newdep

#3
very nice !,



I though of doing this too, but you are there first ;-)

(because Lisp is one bg flexible dbase ;-)



Ill have a closer look...





PS: next step is a dbase tuner ;-)



Norman.
-- (define? (Cornflakes))

cormullion

#4
Or:


(define (truncate1 lst size)
  (0 size (append lst (dup nil size))))


If you like implicit slices...