Giter Club home page Giter Club logo

Comments (4)

muxspace avatar muxspace commented on July 18, 2024

Hi, thanks for the suggestion, but I'm not quite sure what you're trying to accomplish. If you want an inline lambda expression, why wouldn't you simply use something like function(x) x + 5? I'm a bit bleary-eyed from putting together my discrete math course, so perhaps I'm missing something obvious.

from lambda.r.

houshuang avatar houshuang commented on July 18, 2024

Simply because I wanted something shorter :) I know it's silly, but I am so
used to Haskell, where you would do

folder + 0 [1 2 3] #-> 6

or Clojure where you can do

(map #(% * 2) [1 2 3]) #-> [2 4 6]

or Apple's new Swift where you can do

[1,2,3,4].map {$0 * 2}

After that, lapply(c(1,2,3), function(x) x * 2) seems too verbose :)

On Mon, Jun 9, 2014 at 3:27 PM, Brian Lee Yung Rowe <
[email protected]> wrote:

Hi, thanks for the suggestion, but I'm not quite sure what you're trying
to accomplish. If you want an inline lambda expression, why wouldn't you
simply use something like function(x) x + 5? I'm a bit bleary-eyed from
putting together my discrete math course, so perhaps I'm missing something
obvious.

β€”
Reply to this email directly or view it on GitHub
#20 (comment).

http://reganmian.net/blog -- Random Stuff that Matters

from lambda.r.

houshuang avatar houshuang commented on July 18, 2024

Updated with some examples

> filter(">2", c(1,2,3,4))
[1] 3 4

> reduce("%+%2", 0, c(1,2,3))
[1] 6

On Mon, Jun 9, 2014 at 3:38 PM, Stian HΓ₯klev [email protected] wrote:

Simply because I wanted something shorter :) I know it's silly, but I am
so used to Haskell, where you would do

folder + 0 [1 2 3] #-> 6

or Clojure where you can do

(map #(% * 2) [1 2 3]) #-> [2 4 6]

or Apple's new Swift where you can do

[1,2,3,4].map {$0 * 2}

After that, lapply(c(1,2,3), function(x) x * 2) seems too verbose :)

On Mon, Jun 9, 2014 at 3:27 PM, Brian Lee Yung Rowe <
[email protected]> wrote:

Hi, thanks for the suggestion, but I'm not quite sure what you're trying
to accomplish. If you want an inline lambda expression, why wouldn't you
simply use something like function(x) x + 5? I'm a bit bleary-eyed from
putting together my discrete math course, so perhaps I'm missing something
obvious.

β€”
Reply to this email directly or view it on GitHub
#20 (comment).

http://reganmian.net/blog -- Random Stuff that Matters

http://reganmian.net/blog -- Random Stuff that Matters

from lambda.r.

muxspace avatar muxspace commented on July 18, 2024

Ah okay :) I've thought about how to shorten lambdas as well, but decided it wasn't worth it unless I added some of the other features of lambda.r (e.g. pattern matching) to it. Funny, as I've already been accused of adding "syntactic alum" to R because of lambda.r syntax, so I'm not sure whether this would improve the situation or not. There's probably a way to do it with lazy evaluation and deparsing to make it cleaner, though I'd have to think about what type of interface would make sense.

from lambda.r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.