Arc Forumnew | comments | leaders | submitlogin
1 point by goolu 6083 days ago | link | parent

I really appreciate your help. I will try this later tonight. thanks


1 point by thaddeus 6083 days ago | link

no problem.

P.S.You may want to check out the function 'in'. Depends on how you're pulling the items to check against. If it's a list as you suggested then 'find', or looping through 'each' is probably the best, but if they are separate arguments 'in' may be easier. T.

-----

1 point by goolu 6083 days ago | link

awesome. second approach (tostring) worked. I tried to put your code and came up with this: (def test-list (mystring item-list) (each item item-list (if (findsubseq mystring (tostring (pr item))) (prn item)) ) )

arc> (test-list "google" '(yahoo yahoogoogle "google yahoo")) yahoogoogle google yahoo

i was trying to use car on list..but it dint worked. Thanks

-----

1 point by thaddeus 6083 days ago | link

As a note - you dont need (tostring (pr item)) ....unless you want the output of each result to be a string. you could just use (string item).

Here's another method just for the sake of learning:

This method does a few things..(which maybe good or bad).

     * it returns it in a list format for re-use.
     * it maintains the original 'type'.
     * it still preserves the original order.

    (def test-list (mystring item-list) 
         (rev (accum tolist 
	          (each item item-list 
		      (if (findsubseq mystring (string item))
			      (tolist item)))))) 


    arc> (test-list "google" '(yahoo yahoogoogle "google yahoo"))
    (yahoogoogle "google yahoo")

-----

1 point by goolu 6083 days ago | link

awesome. second approach (tostring) worked. I tried to put your code and came up with this: (def test-list (mystring item-list) (each item item-list (if (findsubseq mystring (tostring (pr item))) (prn item)) ) )

arc> (test-list "google" '(yahoo yahoogoogle "google yahoo")) yahoogoogle google yahoo

i was trying to use car on list..but it dint worked. Thanks

-----