Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pop function for lists
#9
It turns out that treating the data in your programs as immutable values can be hugely beneficial in terms of how to think about programs - Rich Hickey has an excellent talk on this, titled The Value of Values. It's a shame that we still teach people how to program quite imperatively; most languages these days have a lot of useful abstractions that let you program more declaratively. The problem here can be expressed as: pair up each item with its index (enumerate), keep the pairs with the indices that you want (filter) and then from each pair, select only the items (map). The list comprehension shown above neatly expresses that. Kevlin Henney has a great talk on programming declaratively, titled Declarative Thinking, Declarative Practice and the Toolz library provides a set of functions to help programming that way, beyond what's in the standard library.
Reply


Messages In This Thread
Pop function for lists - by jamesaarr - Aug-24-2021, 11:57 AM
RE: Pop function for lists - by naughtyCat - Aug-24-2021, 12:44 PM
RE: Pop function for lists - by deanhystad - Aug-24-2021, 07:56 PM
RE: Pop function for lists - by naughtyCat - Aug-26-2021, 10:25 AM
RE: Pop function for lists - by jamesaarr - Aug-25-2021, 07:55 AM
RE: Pop function for lists - by deanhystad - Aug-25-2021, 01:30 PM
RE: Pop function for lists - by jamesaarr - Aug-25-2021, 02:08 PM
RE: Pop function for lists - by DeaD_EyE - Aug-25-2021, 03:09 PM
RE: Pop function for lists - by ndc85430 - Aug-26-2021, 06:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Use ranking function for different lists klatlap 6 2,101 Feb-15-2022, 11:31 PM
Last Post: klatlap
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,524 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  Reading Multiple Lists Using SUM function dgrunwal 6 3,521 Jun-03-2020, 08:23 PM
Last Post: dgrunwal
  Money conversion - problems with lists and .format function fatherted99 1 1,869 Mar-12-2020, 06:29 PM
Last Post: ndc85430
  Using function argument in lists comprehension. blackknite 5 3,167 Apr-23-2019, 09:59 PM
Last Post: snippsat
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,413 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

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