Comments (4)
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.
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.
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 dofolder + 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.
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)
- Preserve unevaluated arguments during dispatching
- typeclass and multiple deriving HOT 4
- No acceptance NULL for a default value HOT 5
- How do type check constructors? HOT 11
- Implement Haskell style typeclass? HOT 1
- Equivalent of `let` in lisp? HOT 4
- Nested %as% does not work HOT 1
- Function types HOT 6
- More specific error messages in guards HOT 4
- StatET cannot index lambda.r functions HOT 3
- Doesn't accept `call` as a function type parameter HOT 3
- dplyr pipes + arithmetic functions causes parsing error
- S4 support in inputs HOT 6
- Function parameter matching bug HOT 6
- README notes HOT 2
- Converting from type A to type B creates third type (B/A) HOT 2
- BUG: install.packages("lambda.r") fails in R-devel w/ _R_CHECK_LENGTH_1_LOGIC2_=true HOT 9
- Pipe operator bug HOT 1
- Inheritance of class breaks type safety HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lambda.r.