Thursday, April 09, 2009

[newLISP] reverse-find

I've always thought learning Lisp would be a good thing to do. The purists may argue that newLISP is not the best place to start. Oh well, too bad.

Below is my first (ever) lambda expression, a port of the VBScript RevInstr() function.


I must say I'm impressed with newLISP. Note that the minus (-) function above can receive more than one argument. A lot of the functions are like that.

Using the reverse-find is very like the (find) function, as below



One thing that differentiates my lambda expression from the in-built find, is in the manner in which an error is flagged.



I'm not sure at this point why the difference and what to do about it. In my use of (find) I check for a result equal to nil, but with (reverse-find) I have to check to see if the result is a string. For example,



Doubtless, someone in the
newLISP Fan Club will set me straight soon.

© Copyright Bruce M. Axtens, 2009

6 comments:

Kazimir Majorinc said...

Hi.

Because your reverse-find at one moment does something like

( - 7 nil)

where nil is returned from find.

You have very interesting blog.

Anonymous said...

newLisp is not the best place to start. There are plenty of great Common Lisp and Scheme implementations to choose from.

BTW.

(defun reverse-find (x seq) (find x seq :from-end t))

Cheers

Marco

Kazimir Majorinc said...

I must disagree with Marco. I used all three as my primary programming languages for some time. By my experience, Newlisp is the simplest of the tree, and Scheme is simpler than Common Lisp. Only one Lisp dialect of the similar simplicity is Pico Lisp. Interested readers can check my blog for lot of examples of Newlisp code.

Anonymous said...

instead of:

(set 'reverse-find (lambda (...) ...))

you can just say:

(define (reverse-find ...) ...)

its the same :-)

newlisper said...

Hi Bruce - didn't realise you had newlisp entries on here... Hope you're having fun with the language...

I think newLISP is a great place to start - move on if and when you want to, not when others tell you.

I see you've met the grumpy (and easily upset) Common Lispers already. Don't worry, they can be safely ignored. Common Lisp is one of the very few languages that comes complete with an implementation of 'lisp condescension', This makes it particularly easy (apparently) to lapse into sneering at other people's interests.

Karenality said...

It's been years since I learned VBScript thru basic programming at school for my Web Development degree. I am now working for an Aerospace company and am in need of 2 VBScript snippets that will enable us to (We're coding 2 Macro-buttons) when the text is selected, for one block of text to turn blue when the button is pressed and the other button will turn the text red with a strike-thru. Thank you for any help you can give!