Python isn't quite so bad.
>>> sum((x + 2.91) / 0.4 for x in range(10)) # python
185.25000000000003
>>>
I find the sum function somewhat "windows" like in that some common
operations are especially easy. The reduce function was demoted from
builtin to a library in python3. Why work under these repressive
constraints?
+/ 0.4 %~ 2.91 + i. 10 NB. j
185.25
Let's remember gawk:
$ gawk 'BEGIN{for(x=0;x<10;++x)a+=(x + 2.91) / 0.4;print a;exit}'
185.25
>Date: Sat, 15 Feb 2014 12:04:13 -0500
>From: Lee Fallat <ircsurfe...@gmail.com>
>To: programm...@jsoftware.com
>Subject: Re: [Jprogramming] awk-like J sentences?
>
>Message-ID:
> <cakzhxzhxcyhdzzccvgvgaftzqxxgvmqwzstfholfu0m4g+a...@mail.gmail.com>
>Content-Type: text/plain; charset=UTF-8
>
>Thanks for the explanation Raul.
>
>I think I understand now that string manipulation in J is
>non-trivial...I was following right up until the very last J sentence
>( 'hi',:&.(-&(a.i.'*'))&.(a.&i.)'there'), mostly because I still only
>know a few verbs. I am starting to think J is either not for me, or my
>way of thinking really needs to change for this language. There are so
>many things that would seem straight forward in traditional languages
>than J, but I will have to see!
>
>Some examples of what I'm thinking of would be difficult or different
in J:
>Passing 3 or more parameters to a verb
>Turning a vector into a list of arguments
>...loops? From what I've seen loops are built into some verbs (+/ -/
>etc), but what if you wanted to do say: add every number in the
>vector, but for every number add 2.91, then divide that by 0.4?
>In python:
>range() generates a list of numbers from 0 to 9.
>for x in range(0,10)
> y += (x + 2.91) / 0.4
>One other thing is interacting with the operating system...How do I
>check to see if files, or even directories exist? Can you create
>directories, or change permissions of files with J? The scope of J
>seems to be very constrained to mathematics. It would be nice to use J
>as a system programming language! Are there any examples of people
>doing these things?
>
>Anyways, I apologize for being off-topic, but just some things I've
>been thinking about. Like I said I still have to get through some more
>learning material.
>
>Regards,
>
>Lee
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm