Python Forum
Using lambdas and map() to parse substrings in a single line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using lambdas and map() to parse substrings in a single line
#5
I'm reading the thread on a phone and also don't have much time to go through all of your posts in great detail right now, but some things stood out:

The first argument to map is the function, not the iterable.

There is no "iterating over a function". As I mentioned, map iterates over the iterable calling the function on each of the items. That much should be obvious from the examples you showed of squaring and doubling each item in the tuples given.
As an exercise, could you write a for loop for each of those caees You'll see that those loops look very similar; the only thing that varies is the function you're calling on the items. Once you realise that, you could write your own version of map by putting that loop inside a function whose arguments are the iterable and the function to transform each item.
Reply


Messages In This Thread
RE: Using lambdas and map() to parse substrings in a single line - by ndc85430 - Sep-18-2020, 11:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Substitue multiple substrings in one command Pavel_47 0 917 Jul-18-2022, 01:24 PM
Last Post: Pavel_47
  Presenting multiline data into single line aaronbuhu 1 1,867 Aug-05-2021, 10:57 AM
Last Post: jamesaarr
  Find string between two substrings, in a stream of data xbit 1 2,234 May-09-2021, 03:32 PM
Last Post: bowlofred
  beginner text formatting single line to column jafrost 4 3,335 Apr-28-2021, 07:03 PM
Last Post: jafrost
  Parse String between 2 Delimiters and add as single list items lastyle 5 3,534 Apr-11-2021, 11:03 PM
Last Post: lastyle
  Print characters in a single line rather than one at a time hhydration 1 2,097 Oct-10-2020, 10:00 PM
Last Post: bowlofred
  Python convert multi line into single line formatted string karthidec 2 9,699 Dec-23-2019, 12:46 PM
Last Post: karthidec
  command line input (arg parse) and data exchange Simba 7 4,466 Dec-06-2019, 11:58 PM
Last Post: Simba
  Print string in a single line RavCOder 8 4,404 Nov-08-2019, 09:45 AM
Last Post: perfringo
  Python-for loop print into single line dragan979 4 7,172 Nov-23-2018, 01:01 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020