473,379 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Can someone describe what these functions do?

6
Expand|Select|Wrap|Line Numbers
  1. def swime(lst):
  2.     p = lst[0]
  3.     S = []
  4.     B = []
  5.     for x in lst:
  6.         if x < p:
  7.             S.append(x)
  8.         else:
  9.             B.append(x)
  10.     return S + swerve(B)    
  11.  
  12. def swerve(lst):
  13.     result = []
  14.     for x in lst:
  15.         if x > 0:
  16.             result.append(x)
  17.     result.sort()
  18.     return result
  19.  
  20.  
With these two functions, I'm not really sure what the first one does ? Can anyone explain it to me ? I understand the swerve function but not the swime one 0.o
Dec 10 '08 #1
2 1453
Dormilich
8,658 Expert Mod 8TB
it's the same as swerve() only it uses the first element of lst as treshold instead of 0.
Dec 10 '08 #2
bvdet
2,851 Expert Mod 2GB
It appears that swime() may be the primary function. It breaks up a list into two lists (S and B), S with items that evaluate less than list element 0 and B with list element 0 and the others that evaluate greater than list element 0. It then returns the sum of S and the list returned by swerve(B).

BV
Dec 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
6
by: Helmut Giese | last post by:
Hello out there, I am a rather experienced C programmer. However, today I got a javascript assignment because someone left (something like: "You're a great programmer - you'll handle this.") and I...
4
by: BinWang85 | last post by:
The following is the code: #include <iostream.h> #include <math.h> //needed for decimal calculations int main() { int employee_num; double FetchHours(void);
7
by: Phlip | last post by:
C++ dudes and dudettes: Ogle this code: static char * p; struct Q { char * p; }; static Q q; int main() { assert(p == NULL);
1
by: Daniel | last post by:
Can someone please describe why impersonation requires the impersonator to be local admin?
12
by: Serman D. | last post by:
Hi all, How do I describe non-table objects, like UDF functions and procedures, using db2's normal command line interface? Database server = DB2/LINUX 9.1.0 Express-C running on Linux 2.6...
1
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
1
by: mansa | last post by:
a) A company receives hundreds of orders every week through the mail. Explain carefully how BATCH- PROCESSING might be used. Describe the role of the BATCH TOTAL in this process. Explain how batch...
8
by: cbtguy_2000 | last post by:
Is it possible to execute the DESC tablename command using PHP to a Oracle DB or is that a *SQLPlus command?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.