Author Topic: string manipulation  (Read 5497 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: string manipulation
« Reply #15 on: July 01, 2006, 08:22:35 PM »
Quote
It is better to find approximate solution to an exact problem than to find an exact solution to approximate problem.
Author Unknown
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

matrix2005in

  • Guest
Re: string manipulation
« Reply #16 on: July 02, 2006, 12:22:22 AM »
hi

this is what i want excellent code...thanks verymuch

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: string manipulation
« Reply #17 on: July 02, 2006, 01:26:00 AM »
I want excellent code, too, but alas, all I have is me to write it .....  :evil:

mathew, a well placed period "." or comma "," would change the meaning of that sentence quite a bit.... :-)

Kerry, I knew we were right and Jon was missing the mark.  :kewl:

CAB, well quoted!

Andrea

  • Water Moccasin
  • Posts: 2372
Re: string manipulation
« Reply #18 on: July 02, 2006, 08:01:23 PM »
this is mine...
Code: [Select]
(setq t1 "ABCDEFGHIJK")
(setq list2 nil)
(while (/= t1 "")
  (setq list1 (substr t1 1 3))
  (setq list2 (append list2 (list list1)))
  (setq t1 (substr t1 4))
)
(foreach n list2
  (if (not text1)(setq text1 " "))
  (setq text1 (strcat text1 " " n))
)
(setq text2 (substr text1 3))

text2 = "ABC DEF GHI JK"

list2 = ("ABC" "DEF" "GHI" "JK")
« Last Edit: July 02, 2006, 08:11:06 PM by Andrea »
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: string manipulation
« Reply #19 on: July 03, 2006, 06:17:12 AM »
hi

...thanks verymuch

Have a play with this too .. though not as easy to understand, perhaps ..

Code: [Select]
;;---------------------------------------------------------------------------
(DEFUN numsOnly (str /)
    (VL-LIST->STRING (VL-REMOVE-IF-NOT '(LAMBDA (n) (AND (> n 47) (< n 58)))
                                       (VL-STRING->LIST str)
                     )
    )
)
;;---------------------------------------------------------------------------
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: string manipulation
« Reply #20 on: July 03, 2006, 07:46:51 AM »
Code: [Select]
(defun test (str)
  ; Not used VL-...
  (if (= str "")
    ""
    (if (< 47 (ascii str) 58)
      (strcat
(substr str 1 1)
(test (substr str 2))
      ) ;_  strcat
      (test (substr str 2))
    ) ;_  if
  ) ;_  if
) ;_  defun