Re: Is this PEP-able? fwhile

Discussion in 'Python' started by Joshua Landau, Jun 25, 2013.

  1. On 24 June 2013 23:50, Chris Angelico <> wrote:
    >
    > In more free-form languages, I implement this by simply omitting a line-break:

    ....
    > Python could afford to lose a little rigidity here rather than gain
    > actual new syntax:
    >
    > for i in range(10): if i%3:
    > print(i)
    >
    > And there you are, the for-if "filtered iteration" model, just by
    > relaxing one rule.


    Maybe rather:

    for i in range(10); if i%3:
    print(i)


    One of the awesomer things about Coffeescript is:

    decorator = (f) -> (args...) -> f(args[0])

    Which lets you do stuff like:

    recursive = do -> r = (n) ->
    if n > 0 then n*r(n-1) else 1

    instead of:

    def recursive_gen():
    def recursive(n):
    return n*recursive(n-1) if n > 0 else 1
    return recursive
    recursive = recursive_gen()

    Of course, Coffeescript has its own quirks.
    Joshua Landau, Jun 25, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    98
    Chris Angelico
    Jun 26, 2013
  2. Ian Kelly

    Re: Is this PEP-able? fwhile

    Ian Kelly, Jun 24, 2013, in forum: Python
    Replies:
    7
    Views:
    104
  3. Ian Kelly

    Re: Is this PEP-able? fwhile

    Ian Kelly, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    92
    Ian Kelly
    Jun 24, 2013
  4. Fábio Santos

    Re: Is this PEP-able? fwhile

    Fábio Santos, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    98
    Fábio Santos
    Jun 24, 2013
  5. Joshua Landau

    Re: Is this PEP-able? fwhile

    Joshua Landau, Jun 24, 2013, in forum: Python
    Replies:
    0
    Views:
    94
    Joshua Landau
    Jun 24, 2013
Loading...

Share This Page