Thanks! In addition to Tomas answer, I can do

f = (a,b) -> f2(3, a, b)

Since both options work for me, which one do you guys think is more legible?
Joan

El miércoles, 4 de junio de 2014 11:51:46 UTC+1, Mauro escribió:
>
> You can also make an anonymous function and assign it to a variable: 
> ff = (x,y) -> f2(3,x,y) 
>
> But Thomas' suggestion is nicer: 
> > f(a,b) = f2(3,a,b) 
>
> The anonymous function approach is shorter if you need to pass it to a 
> function, e.g.: 
> map(x -> f2(3,4,x), 1:5) 
>
> But I think they have not the same performance as proper functions. 
>
> On Wed, 2014-06-04 at 11:39, tomas....@gmail.com <javascript:> wrote: 
> > I don't think you can avoid f1 completely, but there is a one-line 
> syntax 
> > to obtain the same thing: 
> > 
> > f1(a,b) = f2(3,a,b) 
> > 
> > I can't imagine a syntax to express that thing that is more compact yet 
> > equally expressive. 
> > 
> > // T 
> > 
> > On Wednesday, June 4, 2014 12:37:47 PM UTC+2, joanenric barcelo wrote: 
> >> 
> >> First of all, sorry if the question in the title is not well explained. 
> >> Basically, what I want to know if some of you guys know a nicer way to 
> do 
> >> the following: 
> >> 
> >> function f2(a, b, c) 
> >>  return a+b+c 
> >> end 
> >> 
> >> f = function f1(a,b) 
> >>  f2(3,a,b) 
> >> end 
> >> so 
> >> f(1,1) 
> >> is 5 
> >> 
> >> What I want to do is to create a new function "f" which is similar to 
> "f2" 
> >> but with only two arguments. The first argument is implicit. 
> >> Anyone knows how f1 can be avoided? Thanks!! 
> >> 
> >> Joan 
> >> 
>
>

Reply via email to