Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python

Name: Anonymous 2013-03-25 17:14

Hey /prog/,

How can I do this?

We can represent tables in Python as lists of lists as the following:

X0 Y0
X1 Y1

We could use [["X0", "Y0"], ["X1", "Y1"]].

Write a function called merge_tables, that consumes two list of lists (table1 and
table2) and produces a list of lists that corresponds to the merged version of the two
consumed tables. In order to merge the tables we follow certain rules:

• The first column of both table1 and table2 is called the key and the same key
value can occur in both tables or in only one table.

• If table1 has m columns and table2 has n columns then the produced table
will have m+n-1 columns (the key should not be repeated twice in the
produced rows).

• The columns in the produced table should be in the same order as all the
columns in table1 followed by all but the first column in table2.

• Every row in a table has the same number of columns.

• The rows in the produced table do not have a specified order.

• If the the same key value occurs in both tables the two rows should be merged
in the produced table. The key links the two tables.

• There may be multiple rows in table1 or table2 which contain the same key.
In this case the rows should be merged with all rows from the other table with a
matching key. See key “D” in the example below.

• If a key in one table has no match in the other table the value None should be
placed in the missing column fields. The first column in the produced table
should always be the key.

• If both consumed tables are empty then the empty table is produced.

• If only one of the consumed tables is empty then either table1 or table2 is
produced, whichever one is non-empty.

With the example,

merge_tables([["A", 11], ["B", 22], ["D", 33], ["D", 44], ["E", 55]], [["A", True, 5.0], ["B", False, 8.0], ["C", True, 4.0], ["D", False, 2.0], ["D", True, 1.0]]) =>

[["A", 11, True, 5.0],["B", 22, False, 8.0], ["D", 44, False, 2.0], ["D", 44, True, 1.0], ["D", 33, False, 2.0], ["D", 33, True, 1.0], ["C", None, True, 4.0], ["E", 55, None, None]]

Name: Anonymous 2013-03-26 14:07

ספר זה מלמד JavaScript צעד אחר צעד. ספר זה מלמד תכנות ומיועד למי שלמד HTML בעבר ורוצה לדעת לתכנת אתרים דינמיים. הספר מתחיל מתוכניות פשוטות מאוד, ובכל נושא יש דוגמאות, תרשימים וכלים העוזרים להבנת הנושאים. למי שלמד את הפרקים הראשונים או שלמד JavaScript בעבר, ספר זה מלמד תיכנות ברמה גבוהה ושימוש בספריות JavaScript.

שפת JavaScript נמצאת בשימוש במיליארדי דפים ברשת התורמת לשיפור העיצוב, לתקיפות טפסים, זיהוי דפדפנים, יצירת אנימציות וכו'. נוסף לכך, ככל שהזמן הולך, הישומים באינטרנט הופכים לפופולריים יותר. דוגמאות טובות לכך הם השירותים של גוגל כמו גוגל דוקס.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List