Given is a list of the numbers from 1 to 4, calculate the power of 2 for every number and then sum up the results.
The JVM has a huge amout of libraries and products.
Products: Apache Tomcat, Jetty, JBoss
IntStream.rangeClosed(1, 4).map(n -> n * n).reduce(Integer::sum).getAsInt()
Kotlin is the preferred programming language for the Android platform.
Products: IntelliJ IDEA, Trello
(1..4).map({n -> n * n}).sum()
Groovy was originally designed as the standard script language for java. You can create Domain-specific language very easy with groovy.
Products: Gradle, Grails, Spock
(1..4).collect { it * it }.sum()
Products: Apache Spark, Apache Kafka, Akka
(1 to 4).map { n => n * n }.sum
(reduce + (map #(* % %) (range 1 5)))
Code can compiled and replaced in a running system remotely without restarting the server. The languages ar erlang and elixir.
Products: RabbitMQ, Couchbase Server, Riak
lists:sum(lists:map(fun(X) -> math:pow(2,X) end, lists:seq(1,4))).
1..4 |> Enum.map(fn n -> n * n end) |> Enum.sum()
Products: Ruby on Rails, Puppet
(1..4).map { |n| n * n }.sum()
Products: ansible, yum, ubuntu software center, Django, Google App Engine, Mercurial, OpenStack
sum([ n * n for n in range(1, 5) ])
Products: Emacs
In common list you have to extend the language with your own range command:
(defun range (max &key (min 0) (step 1))
(loop for n from min below max by step
collect n))
Now we can use it:
(reduce #'+ (map 'list (lambda (x) (* x x)) (range 5 :min 1)))