Re: clip and chop down consecutive "internal" white spaces to one space??
Joe, LindsayYes! they both do it and are MUCH slicker :) than the improvement I managed overnight i.e. moving the clip down into the for loop :) That's great. Thank you very much. (de shrink (Str) (pack (let (Last_ch "A") (make (for Ch (clip (chop Str)) (if (<> Ch " ") (if (= Last_ch " ") (link (pack " " Ch)) (link Ch))) (setq Last_ch Ch)) Best Regards Dean On 18 February 2017 at 06:39, Lindsay John Lawrence < lawrence.lindsayj...@gmail.com> wrote: > > (de trimmr (S C) >(default C " ") >(glue C (filter '((E) E) (split (chop S) C > > : (setq Str " spaaaces, spaaaces everywhere spaaaces spaaaces r so > squuare ") > -> " spaaaces, spaaaces everywhere spaaaces spaaaces r so squuare " > : (trimmr (trimmr Str) "a") > > -> "spaces, spaces everywhere spaces spaces r so squuare" > > /Lindsay >
Re: clip and chop down consecutive "internal" white spaces to one space??
(de trimmr (S C) (default C " ") (glue C (filter '((E) E) (split (chop S) C : (setq Str " spaaaces, spaaaces everywhere spaaaces spaaaces r so squuare ") -> " spaaaces, spaaaces everywhere spaaaces spaaaces r so squuare " : (trimmr (trimmr Str) "a") -> "spaces, spaces everywhere spaces spaces r so squuare" /Lindsay
Re: clip and chop down consecutive "internal" white spaces to one space??
fun does this do it? (pack (mapcon '((X) (ifn (= '(" " " ") (head 2 X)) (cons (car X (chop S))) -> " this contains 2 consecutive spaces " On Feb 17, 2017 5:23 PM, "dean" wrote: > I've done this and it works but...is there a slicker way :) > > (setq S " this contains 2 consecutive spaces ") > > (de shrink (Str) >#can't clip before inner pack so need to pack, chop, clip and re-pack >(pack > (clip > (chop > (pack >(let (Last_ch " ") >(make > (for Ch (chop Str) > (if (<> Ch " ") > (if (= Last_ch " ") >(link (pack " " Ch)) >(link Ch))) > (setq Last_ch Ch) > > > (prinl "'" (shrink S) "'") > > #'this contains 2 consecutive spaces' > > >