Search found 294 matches
- 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 ...
- 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...
- Thu Oct 20, 2005 9:18 pm
- Forum: newLISP newS
- Topic: newLISP now on Graham's list
- Replies: 55
- Views: 49465
- 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...
- 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))...
- Thu Aug 18, 2005 3:13 pm
- Forum: Anything else we might add?
- Topic: random-sequence
- Replies: 15
- Views: 6781
- Thu Aug 18, 2005 2:52 pm
- Forum: Anything else we might add?
- Topic: random-sequence
- Replies: 15
- Views: 6781
Oops.
Ed.
Code: Select all
(define (random-sequence n m)
(let (L (sequence n m))
(map (lambda (x) (pop L x)) (rand m m))))
- Thu Aug 18, 2005 2:50 pm
- Forum: Anything else we might add?
- Topic: random-sequence
- Replies: 15
- Views: 6781
Another version.
Ed
Code: Select all
(define (random-sequence n m)
(let (L (sequence 1 10))
(map (lambda (x) (pop L x)) (rand m m))))
- Mon Jun 27, 2005 2:26 pm
- Forum: Whither newLISP?
- Topic: READ
- Replies: 20
- Views: 16832
- 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.
Afterwards, data will have the unevaluated S-expression from the file.
Eddie
Code: Select all
(eval-string (append "(define data '" (read-file "fname") ")"))
Eddie
- Thu Jun 23, 2005 8:02 pm
- Forum: Whither newLISP?
- Topic: READ
- Replies: 20
- Views: 16832
If you are reading from a file:
If you just want to evaluate something from the console
Hope this helps.
Eddie
Code: Select all
(eval-string (read-file "filename"))
Code: Select all
(eval-string (read-line))
Eddie
- Wed Jun 22, 2005 9:25 pm
- Forum: newLISP in the real world
- Topic: file sizes, and cp
- Replies: 2
- Views: 2190
- Wed Jun 22, 2005 9:20 pm
- Forum: newLISP in the real world
- Topic: format
- Replies: 2
- Views: 2236
- 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...
- Tue Jun 14, 2005 8:42 pm
- Forum: newLISP in the real world
- Topic: strange mapping
- Replies: 3
- Views: 2474
- 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...
- 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 ...
Eddie
Put a replace around whatever accesses the URL field. That is ...
Code: Select all
(replace " " (whatever gets the URL field) "_")
- 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 to make tables appear correctly in the past. maybe something like .
Eddie
Code: Select all
<td> </td>
Code: Select all
<Var2>∅</Var2>
Eddie
- Sun Mar 27, 2005 10:03 pm
- Forum: Anything else we might add?
- Topic: indexing
- Replies: 6
- Views: 3383
I was thinking more
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
Code: Select all
(idx1 idx2 list)
(2 4 '(a b c d e f g)) => '(c d e)
Eddie
- 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 ...
- 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
- Fri Mar 25, 2005 2:49 pm
- Forum: Anything else we might add?
- Topic: indexing
- Replies: 6
- Views: 3383
Would something like
?
Eddie
Code: Select all
(0 3 '(a b c d e)) => (a b c d)
(1 2 '(a b c d e)) => (b c)
Eddie
- 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
Eddie
- 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.
Thyping (a 1 2) is as easy to type as a[1][2] and maybe as easy to read?
Eddie
Code: Select all
> (setq a '((1 2) 3))
((1 2) 3)
> (a 1)
3
>
Eddie
- 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.
Thyping (a 1 2) is as easy to type as a[1][2] and maybe as easy to read?
Eddie
Code: Select all
> (setq a '((1 2) 3))
((1 2) 3)
> (a 1)
3
>
Eddie