473,473 Members | 1,672 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Conjunction List

http://codepad.org/MV3k10AU

I want to write like next one.

def conjunction(number=a[1],name=b[1],size=c[1]):
flag = a[0]==b[0]==c[0]
if flag:
for e in zip(number,name,size):
print e

conjunction(a,b,c)

-----------------------------------------------------------------------------------------------------
function args receive sequence element:

def somefunc(name=elm1[1], size=elm2[1], color=elm3[1]):
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

not like two case:
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3):
name = elm1[1]; size = elm1[1]; color = elm1[1] # best solution?
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3, **attr):
for e in zip(attr['name'], attr['size'], attr['color']):
print e,

conjunction(a,b,c, name=a[1], size=b[1], color=c[1]) # many args...
-----------------------------------------------------------------------------------------------------

What's a good approach to get the conjunction nest-list-data?
Jun 1 '08 #1
1 2943
On May 31, 8:01 pm, ccy56...@gmail.com wrote:
http://codepad.org/MV3k10AU

I want to write like next one.

def conjunction(number=a[1],name=b[1],size=c[1]):
flag = a[0]==b[0]==c[0]
if flag:
for e in zip(number,name,size):
print e

conjunction(a,b,c)

-----------------------------------------------------------------------------------------------------
function args receive sequence element:

def somefunc(name=elm1[1], size=elm2[1], color=elm3[1]):
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

not like two case:
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3):
name = elm1[1]; size = elm1[1]; color = elm1[1] # best solution?
for e in zip(name, size, color):
print e,

conjunction(a,b,c)
-----------------------------------------------------------------------------------------------------

def somefunc(elm1, elm2, elm3, **attr):
for e in zip(attr['name'], attr['size'], attr['color']):
print e,

conjunction(a,b,c, name=a[1], size=b[1], color=c[1]) # many args...
-----------------------------------------------------------------------------------------------------

What's a good approach to get the conjunction nest-list-data?
The one you comment with "best solution?" is ok for this example. If
you dislike the repetitive part of setting the flag and getting the
second element of each argument, or especially if you want to
generalize it to more than three arguments, here's one way to do it:

def conjunction(*args):
if not args: return
first = args[0][0]
if all(arg[0]==first for arg in args):
for e in zip(*(arg[1] for arg in args)):
print e
>>conjuction(a,b,c)
('0', 'one', '0%')
('1', 'two', '50%')
('2', 'three', '100%')

HTH,
George
Jun 1 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: massimo | last post by:
Hey, I wrote this program which should take the numbers entered and sort them out. It doesnąt matter what order, if decreasing or increasing. I guess I'm confused in the sorting part. Anyone...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
4
by: JS | last post by:
I have a file called test.c. There I create a pointer to a pcb struct: struct pcb {   void *(*start_routine) (void *);   void *arg;   jmp_buf state;   int    stack; }; ...
3
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h>...
0
by: drewy2k12 | last post by:
Heres the story, I have to create a doubly linked list for class, and i have no clue on how to do it, i can barely create a single linked list. It has to have both a head and a tail pointer, and...
5
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify...
10
by: Rudolf Bargholz | last post by:
Perhaps some kind soul could help me out with an SQL I have been trying all day to get to work, where one colum is just not summing up the way I want it to. I have the following data GRP_SEQ ...
1
by: ccy56781 | last post by:
http://codepad.org/MV3k10AU I want to write like next one. def conjunction(number=a,name=b,size=c): flag = a==b==c if flag: for e in zip(number,name,size): print e
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.