> Changed our mind. It helps keep the people with prerelease books  
> busy. ;-)

Oh great!  I'm going to have to cancel my appearance on "The View"
because of this.

I have mentioned my gripes in the IRC, but for public view I would
love better names for chomp and chop.  In isolation those names are
meaningless, so I suggest:

chomp => rtrim
(rtrim "foo\n") => "foo" is much more clear to me, plus it leaves the
door open for trim and ltrim functions should the need arise.

chop => less
(less "foo") => "fo"
(less "foo" 2) => "f"

With less becoming

(defn ^String less
  "Cuts n characters from the end of a string returning the resulting
string.  If the
  number of cuts is greater than the string length, then nothing
happens.  When the
  number of cuts is not supplied, then the last character is dropped."
  ([^String s] (less s 1))
  ([^String s n]
     {:pre [(pos? n)]}
     (let [cuts (- (count s) n)]
       (if (neg? cuts)
         s
         (subs s 0 cuts)))))

(or http://paste.lisp.org/display/100521 if this is flubbed)

:f

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to