newLISP Fan Club

Forum => newLISP in the real world => Topic started by: axtens on April 08, 2009, 12:36:06 AM

Title: A better way to do this?
Post by: axtens on April 08, 2009, 12:36:06 AM
G'day everyone



I'm starting to like this language. But I'm still approaching it as one who has been 'polluted' by other languages.



Is there a better way to do this?


(dolist
  (i
    (parse
      (read-file "c:\temp\data") "rn"
    )
  )
(begin
(set 'j (reverse (parse i "t")))
(if (not (empty? j))
(begin
;(print j "n")
(set 'k (j 0))
(set 'l (j 1))
;(print (string (cons 'find (list k l 1))))
    (set 'm (eval-string (string (cons 'find (list k l 1)))))
(when (true? m)
;(print m "n")
(print "afti(" l ", " k ")=" (slice l m) "n" )
)
)
)
)
)


Kind regards,

Bruce.
Title:
Post by: HPW on April 08, 2009, 12:46:59 AM
In you first postet version you ask for set and multiple argument:



(set 'k (j 0) 'l (j 1))
Title:
Post by: axtens on April 08, 2009, 12:50:25 AM
Quote from: "HPW"In you first postet version you ask for set and multiple argument:



(set 'k (j 0) 'l (j 1))


Marvellous. Thanks very much.



Bruce.
Title:
Post by: Lutz on April 08, 2009, 01:07:08 AM
instead of:


(set 'm (eval-string (string (cons 'find (list k l 1)))))



you could do:


(set 'm (eval (cons 'find (list k l 1))))

or even better:


(set 'm (apply find (list k l 1))

ps: welcome to newLISP
Title:
Post by: axtens on April 08, 2009, 01:45:50 AM
Quote from: "Lutz"


or even better:


(set 'm (apply find (list k l 1))

ps: welcome to newLISP


Thanks for the welcome. And thanks for the help with the code -- much appreciated!!