ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-list
python-list
Moving list entries from one list to another
by JB other posts by this author
Jul 13 2002 11:08AM messages near this date
Re: Input again | Re: Moving list entries from one list to another
I have two lists <list1>  and <list2>. The entries of these 
lists have the format (id,rest), where <id>  is a natural 
number. The list are sorted, the key is <id> . 
I should like to write a funtion move:

def move(f):

The argument <f>  is a predicate: 
  f: {set of entries of list1} -->  {true, false}
Now all elements of list1, for which <f>  returns true, 
should be moved to list2. It is very important, that 
<list2>  remains sorted, that is, the entries from <list1> 
should be inserted to the right positions in <list2> . When 
<n>  is defined by
n := max(len(list1),len(list2)),
then <move>  should work in O(n) time.

Any hints of how to do this (as fast as possible)?

TIA,
-- 
Janos Blazi


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
-- 
http://mail.python.org/mailman/listinfo/python-list
Thread:
JB
JB
Bengt Richter
JB
Alex Martelli
Bengt Richter
JB
JB
JB
JB
JB
JB
Bengt Richter
Alex Martelli
Alex Martelli
Alex Martelli
Emile van Sebille
=?iso-8859-1?q?Fran=E7ois?= Pinard

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved