Search found 294 matches

by eddier
Tue Nov 01, 2005 2:44 pm
Forum: newLISP in the real world
Topic: roman numerals revisited
Replies: 6
Views: 4468

Look at Sam Cox's version. Here is his algorithm with a few minor changes. Note everything is a pure function with no side effects! (define (->roman n) (let (roman-a '((100 "C") (99 "IC") (90 "XC") (50 "L") (49 "IL") (40 "XL") (10 "X") (9 "IX") (5 "V") (4 "IV") (1 "I"))) (define (roman-aux result n ...
by eddier
Mon Oct 31, 2005 8:41 pm
Forum: newLISP in the real world
Topic: roman numerals revisited
Replies: 6
Views: 4468

roman numerals revisited

Lutz, I've been trying to recode some of my recursive routines to iterative ones. The iterative versions aren't nearly as elegant. For example, recoding a recursive roman numeral conversion to an iterative version looks horrible (below). Looks even worse to maintain, but you're right, it runs signif...
by eddier
Thu Oct 20, 2005 9:18 pm
Forum: newLISP newS
Topic: newLISP now on Graham's list
Replies: 55
Views: 49465

Thanks Lutz,

Dmi posted the dynamic scoping/recursion trick. Credit where credit is due.

Eddie
by eddier
Thu Oct 20, 2005 5:14 pm
Forum: newLISP newS
Topic: newLISP now on Graham's list
Replies: 55
Views: 49465

Lutz, To unreferece memory, do I need to make sure no variable or function is bound to the referenced memory, or do I need to delete the context? I think this is just a question of programming style. There is always the possibility to recode a recursive algorithm in a linear, iterative fashion. Trad...
by eddier
Thu Oct 20, 2005 2:06 pm
Forum: newLISP newS
Topic: newLISP now on Graham's list
Replies: 55
Views: 49465

I really admire Lutz and I think he is genuinely a nice guy, but Qrczak points out two particular problems with newlisp for my current problems: (1) Copying the whole data structure on each function invocation makes my recursive algorithms very memory inefficient (most of the time worse than O(N^2))...
by eddier
Thu Aug 18, 2005 3:13 pm
Forum: Anything else we might add?
Topic: random-sequence
Replies: 15
Views: 6781

Yep you are right!

Ed
by eddier
Thu Aug 18, 2005 2:52 pm
Forum: Anything else we might add?
Topic: random-sequence
Replies: 15
Views: 6781

Oops.

Code: Select all

(define (random-sequence n m)
    (let (L (sequence n m))
      (map (lambda (x) (pop L x)) (rand m m))))
Ed.
by eddier
Thu Aug 18, 2005 2:50 pm
Forum: Anything else we might add?
Topic: random-sequence
Replies: 15
Views: 6781

Another version.

Code: Select all

(define (random-sequence n m)
    (let (L (sequence 1 10))
      (map (lambda (x) (pop L x)) (rand m m))))
Ed
by eddier
Mon Jun 27, 2005 2:26 pm
Forum: Whither newLISP?
Topic: READ
Replies: 20
Views: 16832

I'm sorry I couldn't help.

Eddie
by eddier
Mon Jun 27, 2005 12:29 pm
Forum: Whither newLISP?
Topic: READ
Replies: 20
Views: 16832

Maybe I still don't get it, but what about.

Code: Select all

(eval-string (append "(define data '" (read-file "fname") ")"))
Afterwards, data will have the unevaluated S-expression from the file.

Eddie
by eddier
Thu Jun 23, 2005 8:02 pm
Forum: Whither newLISP?
Topic: READ
Replies: 20
Views: 16832

If you are reading from a file:

Code: Select all

(eval-string (read-file "filename"))
If you just want to evaluate something from the console

Code: Select all

(eval-string (read-line))
Hope this helps.

Eddie
by eddier
Wed Jun 22, 2005 9:25 pm
Forum: newLISP in the real world
Topic: file sizes, and cp
Replies: 2
Views: 2190

Mine keeps the same size too. I'm using Debian testing with the 2.6 kernel. I think thats suppose to use and update the latest libraries. I update every day. But, sometimes cutting edge is a drag because I will get a testing version (broken) of software that over writes a working version.

Eddie
by eddier
Wed Jun 22, 2005 9:20 pm
Forum: newLISP in the real world
Topic: format
Replies: 2
Views: 2236

Thanks Sammo!

Works like a charm :) I didn't know I could use "apply" on functions with a variable number of arguments without defining a lambda or helper function. I can use this knowlege to make more elegant solutions for a lot of other functions as well :)

Eddie
by eddier
Wed Jun 22, 2005 7:55 pm
Forum: newLISP in the real world
Topic: format
Replies: 2
Views: 2236

format

Lutz, I've found use on several occasions to have an optional list of variables or values in format. For instance, suppose L = ("bob" "this" "that" 3 2 10 "a" 96 "----" 456). We could write (println (format "%s,%d,%s,%d\n" (select L 0 4 1 7))) vs (println (format "%s,%d,%s,%d\n" (L 0) (L 4) (L 1) (L...
by eddier
Tue Jun 14, 2005 8:42 pm
Forum: newLISP in the real world
Topic: strange mapping
Replies: 3
Views: 2474

Yes,

I was wondering why doesn't map take implicit indexing instead of implicit slicing?

Would it not be more appropriate for map to take indexing? Why would we ever want map to be slicing?

Thanks!

Eddie
by eddier
Tue Jun 14, 2005 5:18 pm
Forum: newLISP in the real world
Topic: strange mapping
Replies: 3
Views: 2474

strange mapping

Suppose (define data '((1 2) (2 3) (3 4))) (println (map first data)) => (1,2,3) Okydoky! That's what I expect. But, (println (map 0 data)) => ((1 2) (2 3) (3 4)) and (println (map 1 data)) => ((2) (3) (4)) Looks like (map n list ) means appling ( n sublist) instead of (sublist n ). Shouldn't this b...
by eddier
Fri Apr 22, 2005 3:52 pm
Forum: newLISP in the real world
Topic: using cgi.lsp
Replies: 1
Views: 1987

Try the following

Put a replace around whatever accesses the URL field. That is ...

Code: Select all

(replace " " (whatever gets the URL field) "_")
Eddie
by eddier
Wed Apr 06, 2005 1:01 pm
Forum: newLISP in the real world
Topic: Empty string-vars in XML
Replies: 6
Views: 3973

I know html is not xml but I have used

Code: Select all

<td>&nbsp;</td>
to make tables appear correctly in the past. maybe something like

Code: Select all

<Var2>&empty;</Var2>
.

Eddie
by eddier
Sun Mar 27, 2005 10:03 pm
Forum: Anything else we might add?
Topic: indexing
Replies: 6
Views: 3383

I was thinking more

Code: Select all

(idx1 idx2 list) 

(2 4 '(a b c d e f g)) => '(c d e)
But I'm not sure. The only thing that might be confusing is the position of the number. I still get confused on set-nth and nth-set. There might be a similar problem with implicit indexing and slicing.

Eddie
by eddier
Fri Mar 25, 2005 3:00 pm
Forum: newLISP and the O.S.
Topic: For the Lazy developer
Replies: 4
Views: 5309

Actually I have done that it in the past when I worked with Windows. I created a batch file with something like that with programs before. The person could drop the file on the icon and it would run. If I remember correctly ??? newlisp prog %1 where the %1 was the file that got dropped. If you want ...
by eddier
Fri Mar 25, 2005 2:52 pm
Forum: Anything else we might add?
Topic: indexing
Replies: 6
Views: 3383

Opps, I didn't see the slice up there. Wouldn't the semantics indicate

Code: Select all

(2 '(a b c d e f g) 3) =>
('(c d e f g) 3) =>
f
?
by eddier
Fri Mar 25, 2005 2:49 pm
Forum: Anything else we might add?
Topic: indexing
Replies: 6
Views: 3383

Would something like

Code: Select all

(0 3 '(a b c d e)) => (a b c d)
(1 2 '(a b c d e)) => (b c)
?

Eddie
by eddier
Thu Mar 24, 2005 9:49 pm
Forum: Anything else we might add?
Topic: indexing
Replies: 6
Views: 3383

indexing

I absolutely LOVE the implicit indexing Lutz. Just one question, can we do something with rest in a similar manar?

Eddie
by eddier
Fri Mar 18, 2005 3:59 pm
Forum: newLISP newS
Topic: implicit indexing
Replies: 1
Views: 2249

implicit indexing

Neat! I've not seen anything quite like this before. The first thing after a non-quoted list is not interpreted as a function.

Code: Select all

> (setq a '((1 2) 3))
((1 2) 3)
> (a 1)
3
> 
Thyping (a 1 2) is as easy to type as a[1][2] and maybe as easy to read?

Eddie
by eddier
Fri Mar 18, 2005 3:52 pm
Forum: newLISP newS
Topic: implicit indexing
Replies: 0
Views: 2119

implicit indexing

Neat! I've not seen anything quite like this before. The first thing after a non-quoted list is not interpreted as a function.

Code: Select all

> (setq a '((1 2) 3))
((1 2) 3)
> (a 1)
3
> 
Thyping (a 1 2) is as easy to type as a[1][2] and maybe as easy to read?

Eddie