newLISP Database

Notices and updates
Locked
kinghajj
Posts: 30
Joined: Sun Jul 15, 2007 2:37 pm

newLISP Database

Post by 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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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:

Code: Select all

(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
Posts: 30
Joined: Sun Jul 15, 2007 2:37 pm

Post by kinghajj »

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

Code: Select all

(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
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Or:

Code: Select all

(define (truncate1 lst size) 
  (0 size (append lst (dup nil size))))
If you like implicit slices...

Locked