A better way to do this?

Q&A's, tips, howto's
Locked
axtens
Posts: 28
Joined: Mon Apr 06, 2009 12:23 pm
Location: Perth, WA Australia
Contact:

A better way to do this?

Post by axtens »

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?

Code: Select all

(dolist 
  (i 
    (parse 
      (read-file "c:\\temp\\data") "\r\n"
    )
  ) 
	(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.

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

In you first postet version you ask for set and multiple argument:

Code: Select all

(set 'k (j 0) 'l (j 1))
Hans-Peter

axtens
Posts: 28
Joined: Mon Apr 06, 2009 12:23 pm
Location: Perth, WA Australia
Contact:

Post by axtens »

HPW wrote:In you first postet version you ask for set and multiple argument:

Code: Select all

(set 'k (j 0) 'l (j 1))
Marvellous. Thanks very much.

Bruce.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

instead of:

Code: Select all

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

you could do:

Code: Select all

(set 'm (eval (cons 'find (list k l 1))))
or even better:

Code: Select all

(set 'm (apply find (list k l 1))
ps: welcome to newLISP

axtens
Posts: 28
Joined: Mon Apr 06, 2009 12:23 pm
Location: Perth, WA Australia
Contact:

Post by axtens »

Lutz wrote:
or even better:

Code: Select all

(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!!

Locked