[erlang-questions] list comprehensions with predefined functions?

Andreas Hillqvist andreas.hillqvist@REDACTED
Wed Jun 18 14:48:05 CEST 2008


Try:
> [mymath:power(X, Y) || X <- [1,2,3] Y <- 3].

> [mymath:cube(X) || X <- [1,2,3]].

> [mymath:sq(X) || X <- [1,2,3]].


Kind regards
Andreas Hillqvist

Den 2008-06-18 skrev Circular Function <circularfunc@REDACTED>:
>
>   how do i use a predefined function in a listcomprehension?
>
> and if i have 2 variables how do I write then?
>
>
> 42> c(mymath).
> {ok,mymath}
> 43> [mymath:power || X <- [1,2,3] Y <- 3].
> * 1: syntax error before: Y
> 43> [mymath:power || X <- [1,2,3], Y <- 3].
> * 1: illegal expression
> 44> [mymath:cube || X <- [1,2,3]].
> * 1: illegal expression
> 45> [X*2 || X <- [1,2,3]].
> [2,4,6]
> 46> [X*X || X <- [1,2,3]].
> [1,4,9]
> 47> [X*2 || X <- [1,2,3]].
> [2,4,6]
> 48> [mymath:sq || X <- [1,2,3]].
> * 1: illegal expression
> 49>
>
> ------------------------------
> Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.
> Sök och jämför hos Yahoo! Shopping.<http://shopping.yahoo.se/c-100015813-bredband.html?partnerId=96914325>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080618/650c5549/attachment.htm>


More information about the erlang-questions mailing list