Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Code Readability (was: perl?)
- Date: Fri, 19 Aug 2016 15:52:49 +0200
- From: Josh Glover <jmglov@example.com>
- Subject: Re: [tlug] Code Readability (was: perl?)
- References: <22451.6786.829094.726@turnbull.sk.tsukuba.ac.jp> <20160819132402.GC30780@quadratic.cynic.net>
On 19 August 2016 at 15:24, Curt Sampson <cjs@example.com> wrote: > A lot of people think about readability as a property of a language, > but that's not right. Really excellent explanation! > def double(xs); xs.map { |x| x*2 }; end Yes! Or better yet, any of these, depending on how Lispy or Clojurey you want to get: (defn double [xs] (map #(* % 2) xs)) (defn double [xs] (map (fn [x] (* x 2)) xs)) (defn double [xs] (map (partial * 2) xs)) (def double (partial map #(* % 2))) > [M]y conventions: > > 1. If you have just a generic number in a small context, call it `x`. > 2. A list of things is the name of the thing with an `s` on the end. > 3. Put short stuff on a single line. > 4. Don't use extra characters and extra lines for do/end when you > can use the shorter braces {} that also let you do paren matching YES to all four! > The long and short of it is: > > First, write for your audience. > Second, try to work with your group to optimize your style. This was some of the best programming advice I've seen distilled into such a short post. Thanks! Cheers, Josh
- References:
- Re: [tlug] perl? (was: Employment for "oldies")
- From: Stephen J. Turnbull
- [tlug] Code Readability (was: perl?)
- From: Curt Sampson
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Moving on from xterm
- Next by Date: Re: [tlug] Code Readability (was: perl?)
- Previous by thread: [tlug] Code Readability (was: perl?)
- Next by thread: Re: [tlug] Code Readability (was: perl?)
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links