Ruby, Python and map

Sometimes the image in one language gets in the way and I can't remember how to write in the other language.

Python


map(lambda n: str(n).rjust(3,"0"), [1,2,3])
>> ["001", "002", "003"]

Ruby


[1,2,3].map{|n| n.to_s.rjust(3,"0")}
>> ["001", "002", "003"]

Recommended Posts

Ruby, Python and map
Python and Ruby split
Python and ruby slice memo
Ruby and Python syntax ~ branch ~
Difference between Ruby and Python split
Scraping with Node, Ruby and Python
python string processing map and lambda
Differences between Ruby and Python in scope
Eating and comparing programming languages: Python and Ruby
Encrypt with Ruby (Rails) and decrypt with Python
Easy web scraping with Python and Ruby
Differences between Ruby and Python (basic syntax)
[python] Compress and decompress
Python and numpy tips
[Python] pip and wheel
Instant method grammar for Python and Ruby (studying)
Batch design and python
Python iterators and generators
Python packages and modules
Vue-Cli and Python integration
Specifying the range of ruby and python arrays
Create a web map using Python and GDAL
Compare the speed of Python append and map
python input and output
Python3, venv and Ansible
Python asyncio and ContextVar
About shallow and deep copies of Python / Ruby
Anonymous and map functions
Comparison of Python and Ruby (Environment / Grammar / Literal)
AtCoder ARC080 D simulation solved in Ruby and Python
[Ruby vs Python] Benchmark comparison between Rails and Flask
Difference between Ruby and Python in terms of variables
[Python] How to create Correlation Matrix and Heat Map
Interprocess communication between Ruby and Python (POSIX message queue)
Comparison of CoffeeScript with JavaScript, Python and Ruby grammar
Version control of Node, Ruby and Python with anyenv
Programming with Python and Tkinter
[Python] Correct usage of map
Python: Class and instance variables
Python 2 series and 3 series (Anaconda edition)
Python and hardware-Using RS232C with Python-
Python indentation and string format
Python real division (/) and integer division (//)
Install Python and Flask (Windows 10)
Java VS PHP VS Python VS Ruby
About python objects and classes
About Python variables and objects
Apache mod_auth_tkt and Python AuthTkt
Å (Ongustromu) and NFC @ Python
Understand Python packages and modules
# 2 [python3] Separation and comment out
Python shallow copy and deep copy
Python installation and basic grammar
Standard input / summary / python, ruby
I compared Java and Python!
Python shallow and deep copy
matplotlib gallery and color map
Zundokokiyoshi with python / ruby / Lua
About Python, len () and randint ()
About Perl, Python, PHP, Ruby
About Python datetime and timezone