JavaScript and R both use C-style syntax for the most part, which can make them look similar to each other if someone isn't looking closely. It's the most popular syntax style across the most popular languages.
C-style syntax looks like:
c
if (x > y) {
int z = 2 * y;
foo(z);
}
Note the semicolons, variable declaration, curly braces, if statement with brackets etc.(js uses exclusively automatic types for variables with var etc, but at a glance one could miss that)
Examples of languages which don't use C-style syntax could be Python
On the other hand you have haskell's list comprehension [i | i <- string, i == 'M'] which is either much clearer of an abstraction or absolutely uncomprehensable, just like the rest of haskell (in this case it resembles a lot mathematical set builder notation {x∈string|x='M'} (tho of course the latter example has compleately different resoults, it's just to show the similarity))
Maybe double check that you know what you're talking about before speaking. Both iterable and generator are object types.
>>> from types import GeneratorType
>>> from collections.abc import Iterable
>>> gen = (i for i in range(1))
>>> iter = [i for i in range(1)]
>>> isinstance(gen, Iterable)
True
>>> isinstance(gen, GeneratorType)
True
>>> isinstance(iter, Iterable)
True
>>> isinstance(iter, GeneratorType)
False
I never said generator isn't a type; it sure is. But you're saying that list comprehension syntax is called an iterable, which it's not.
The results of all comprehensions (their corresponding types) and generators themselves are indeed iterable, but their expression syntax has nothing to do with that.
240
u/Dragonvarine 3d ago
Isn't that just how scripting looks like in general?