Python

python
list(map(lambda x: print(2**x), range(1, int(input())+1)))
[print(2**x) for x in range(1, int(input())+1)]

ruby
(1..gets.to_i).each{|x| puts 2**x}

why is python so ugly?

Other urls found in this thread:

rubyheroes.com/heroes/2016
twitter.com/NSFWRedditVideo

>functional programming in Python
You're doing it wrong

rubyheroes.com/heroes/2016

if this is how you're programming then it must be you who's ugly

Is this bait? That Ruby bit is unreadable.

It's perfectly simple. For each item between 1 and the value the user inputs (not inclusive), print out a line containing 2^x

list(map(lambda x: print(2**x), [x for x in range(int(input())+1)]))

Yes, python is ugly if you can't write it pythonically

Haskell
forM_ (print . (2^)) [1..n]

>Hasklel

Is using map with lambdas in python when list comprehensions are a thing a meme or something?

Also using list comprehensions or even map for side effects is a terrible idea. The first attempt especially screams of not knowing the language well.

>
>using list comprehensions or even map for side effects is a terrible idea
Give me 1 reason why

now you're thinking with objects
process.stdin.setEncoding('utf8')
process.stdin.on('data', i => [...Array(+i[0])].forEach((_, i) => console.log(Math.pow(2, i+1))))

It's not pythonic. If that's not a good enough reason, you're wastefully creating a list of N elements, which is most likely filled with None.

If you really must insist on comprehensions, a generator + consume is a much better idea, but the idiomatic way is to just write a 2 line for loop.

Ugly bloated and for plebs.

>why is python so ugly?
It was designed to cater a specific group of persons (so called "UNIX hackers" and people that use a brainlet language called ABC, each a brand of retard) rather than a a specific use case.

>pythonic
Oh god, this kind of retardness actually exists

>being such a fucking brainlet
[2**(i+1) for i in range(input)]
that's it, user. Now, which is more readable?

Yes, nice arbitrary list of rules they have there.

still ruby
>>> [2**(i+1) for i in range(input)]
Traceback (most recent call last):
File "", line 1, in
TypeError: 'builtin_function_or_method' object cannot be interpreted as an integer

I used input as a variable name for the user's input, by default it's a function. What are you trying to show here? This is just an example. replace it with int(input()) (or raw_input() on python2) for it to work in one line.
My point was that the range only needs one parameter, and is much cleaner than the ruby version.

Most pythonic idioms and pep8 rules have some sort of justification. Even if they're arbitrary, it ends up being easier for everyone using a language if there's one clear way for doing things.

Ruby shines in funcional programming, that is why I like it so much.

obvious b8, but that's what Sup Forums is for, amirite?
for (i

Why are you printing inside a comprehension?