Search found 180 matches

by Sammo
Fri Feb 10, 2006 12:03 am
Forum: newLISP in the real world
Topic: (case) evaluation
Replies: 6
Views: 4060

As this example shows, the expression in the exp-N position in each (exp-N body-N) pair is completely unevaluated. > (set 'a 5) 5 > (set 'test '(eval a)) (eval a) > (eval test) 5 > (case test (5 'zero) ((eval a) 'one) (pete 'two) (true 'magoo)) one That is, no attempt is made to evaluate the express...
by Sammo
Fri Jan 13, 2006 4:18 pm
Forum: newLISP in the real world
Topic: pushing stuff
Replies: 4
Views: 3267

You could write your own version of push -- mypush-- that would be used something like this: (mypush 1 2 3 'a) Notice that I quote the stack (in this case 'a) to prevent it from being evaluated. Something like this (this code doesn't work): (define (mypush) (let ( stack (last (args)) list-of-items (...
by Sammo
Wed Jan 11, 2006 11:34 pm
Forum: Anything else we might add?
Topic: Scheme: reduce & filter (please rate).
Replies: 9
Views: 7231

Being unfamiliar with Scheme's named let, it's hard for me to read the Scheme code. Here is my straightforward newLisp solution which is, I think, tail recursive. ;; recursive version ;; (define (myfilter pred? items) (reverse (myfilter-aux pred? items '())) ) (define (myfilter-aux pred? items resul...
by Sammo
Wed Dec 21, 2005 7:08 pm
Forum: Anything else we might add?
Topic: Christmas Quiz by Newlisper
Replies: 1
Views: 1409

Christmas Quiz by Newlisper

Because I can't figure out how to leave a comment at http://newlisper.blogspot.com, I'll post my answers here: Newlisper's problem statements is: Christmas quiz: four by four Here's a version of a traditional puzzle to exercise your mental maths muscles before Christmas. In newLISP, define symbols z...
by Sammo
Fri Dec 16, 2005 10:44 pm
Forum: Anything else we might add?
Topic: Recusion
Replies: 2
Views: 2040

by Sammo
Wed Dec 07, 2005 9:30 pm
Forum: Anything else we might add?
Topic: Interactive documentation
Replies: 16
Views: 6762

Thanks, cormullion.

This is great! Because it's "nothing but newLisp," it works in Windows, too, with the obvious change.

-- Sam
by Sammo
Tue Dec 06, 2005 11:04 pm
Forum: Anything else we might add?
Topic: Return multiple values from a function.
Replies: 16
Views: 9284

My two cents: Mark wrote: "Ideally I could just put the CAR of the recursive value in the first part of the list and put the new value in CDR however it doesn't want to play that way." In newLisp as well as Scheme, a reasonable approach is to write in the language you wish you had, and then implemen...
by Sammo
Sun Dec 04, 2005 10:09 pm
Forum: Whither newLISP?
Topic: Searching elements in an association list...
Replies: 2
Views: 3864

Improved so that (magoo "no such food" food-lists) returns nil. (define (magoo key aList) (let ( vec (ref key aList) ) ;body of let (and vec (aList (vec 0)) ) )) > (magoo "no such food" food-lists) nil > (magoo "celery" food-lists) ("vegatables" "lettuce" "celery" "cucumbers" "olives" "onions")
by Sammo
Thu Dec 01, 2005 2:01 am
Forum: Whither newLISP?
Topic: Searching elements in an association list...
Replies: 2
Views: 3864

(set 'food-lists '( ("fruit" "bannana" "pear" "apple" "plum" "grapes") ("vegatables" "lettuce" "celery" "cucumbers" "olives" "onions") ("junk food" "ice cream" "licorice" "chocolate bar" "carmel apple" "bubble gum") )) (define (magoo findme a-list) (a-list ((ref findme a-list) 0)) ) Then > (magoo "...
by Sammo
Thu Dec 01, 2005 1:53 am
Forum: newLISP in the real world
Topic: Breaking out of dolist...
Replies: 1
Views: 2140

See the (dotimes ...) example in the Throw section of the help file.
-- Sam
by Sammo
Mon Nov 14, 2005 8:07 pm
Forum: newLISP and the O.S.
Topic: List running processes/applications
Replies: 5
Views: 4501

Hello Hans-Peter,

Yes, I need it in Neobook. The best solution would support Win98 as well as WinNT, Win2K and WinXP.

Thanks,
-- Sam
by Sammo
Sun Nov 13, 2005 11:14 pm
Forum: newLISP and the O.S.
Topic: List running processes/applications
Replies: 5
Views: 4501

List running processes/applications

Does anyone know of a windows function and associated DLL that will return a list of all running processs and/or applications — lists similar to those provided by Task Manager?

Thanks,
-- Sam
by Sammo
Sat Nov 05, 2005 8:01 pm
Forum: Anything else we might add?
Topic: lambda?
Replies: 2
Views: 1724

Thanks, HPW ... macro? it is!
by Sammo
Sat Nov 05, 2005 7:42 pm
Forum: Anything else we might add?
Topic: lambda?
Replies: 2
Views: 1724

lambda?

lambda? returns true as expected in the following:

> (define (bob))
(lambda ())
> (lambda? bob)
true

Should lambda? also return true in the following?

> (define-macro (bob))
(lambda-macro ())
> (lambda? bob)
nil
by Sammo
Fri Nov 04, 2005 5:55 pm
Forum: Anything else we might add?
Topic: fnparse to get all used functions
Replies: 6
Views: 2732

Would something like this work? (define (fnparse SOURCE) (letn ( LP "(" ;) left paren SP " " ; space LPSP "( " ;) left paren and space NULL "" ; null string keep (lambda (L K) (dolist (x L) (if (= (x 0) LP) (push x K))) K) s (parse (replace LPSP (join (parse SOURCE) SP) LP) SP) ) ;body of letn (uniq...
by Sammo
Thu Nov 03, 2005 9:46 pm
Forum: newLISP in the real world
Topic: Just another encounter of newlisp flexibility ;-)
Replies: 7
Views: 4501

(apply max b)
by Sammo
Thu Nov 03, 2005 3:39 pm
Forum: Anything else we might add?
Topic: select column from two-dimension list
Replies: 3
Views: 1968

Code: Select all

(define (select-column lst col)
   (map (fn (row) (row col)) lst) )
by Sammo
Wed Nov 02, 2005 8:16 pm
Forum: newLISP in the real world
Topic: rot13 in pure newlisp no regex(p)
Replies: 16
Views: 9223

(context 'rot13) (define (rot13:aux ch , i) (if (set 'i (find ch "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")) ("nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" i) ch )) (define (rot13:rot13 str) (join (map rot13:aux (explode str))) ) (context 'MAIN) > (silent (setq s (read-file "n...
by Sammo
Wed Nov 02, 2005 12:30 am
Forum: newLISP and the O.S.
Topic: Bug in (int)
Replies: 3
Views: 3308

Hello Christer, It is intentional! Unless told otherwise (see manual), 'int' understands that number strings beginnning with numeral "0" (zero) are octal numbers. Since "08" is not a valid octal number, 'int' stops parsing the octal string at "0" and returns zero as the result. The manual gives comp...
by Sammo
Mon Oct 17, 2005 6:38 pm
Forum: Anything else we might add?
Topic: need some help in lisp
Replies: 3
Views: 2557

Here is a pair of functions that might do the job: (define (good-count N L) (let ;if N=3.3 and L=(1 3 4) then pairs=((1 2.3) (3 0.3) (4 0.7)) ( pairs (map (fn (x) (list x (abs (sub x N)))) L) ) ;body of let ((min-pair pairs) 0) )) (define (min-pair L) (let ( MIN-PAIR (L 0) ) ;body of let (dolist (PA...
by Sammo
Sun Oct 16, 2005 9:31 pm
Forum: Anything else we might add?
Topic: newLISP in 21 minutes
Replies: 7
Views: 3704

Hello Dmi, When I searched Google for "newlisp in 21 minutes" (quotes included), it found a "cached" version for me which I downloaded as an HTML file and then zipped. I can send the zipped file to you (how?) or perhaps you will have similar success with Google or another search engine. Here is the ...
by Sammo
Sat Oct 15, 2005 9:37 pm
Forum: Anything else we might add?
Topic: Suggestions
Replies: 4
Views: 2520

> (setq x '(1 2))
(1 2)
> (setq x (cons x '(3 4)))
((1 2) 3 4)
> x
((1 2) 3 4)
by Sammo
Sun Oct 02, 2005 8:24 pm
Forum: Anything else we might add?
Topic: autodocumentation
Replies: 7
Views: 3871

Based on work in this forum by Nigel Brown and HPW, the function (doc) has already been written. (define (doc f) "(doc f) --> display function f's doc string, if present" (if (and (or (lambda? f) (macro? f))(string?(nth 1 f))) (begin (print(nth 1 f)) (write-line) true) nil)) Using the following func...
by Sammo
Thu Aug 18, 2005 3:05 pm
Forum: Anything else we might add?
Topic: random-sequence
Replies: 15
Views: 6747

Hi eddier,

I think you version works better like this:

Code: Select all

(define (random-sequence n m) 
    (letn (L (sequence n m) N (length L)) 
      (map (lambda (x) (pop L x)) (rand N N)) )) 
by Sammo
Thu Aug 04, 2005 4:04 pm
Forum: Anything else we might add?
Topic: Escaping backslashes in append operation for use in regex
Replies: 2
Views: 2169

try (append "-" o {\s*(\w*)(\s*-|$)}) in which I replaced the double-quote string delimiters with left and right brace string delimiters, instead of (append "-" o "\s*(\w*)(\s*-|$)") Using braces instead of double-quotes removes the need to treat the backslash characters with special care. -- sam