Tayacan's Profile
Reputation: 144
Stalwart
- Group:
- Contributors
- Active Posts:
- 275 (0.32 per day)
- Joined:
- 18-January 11
- Profile Views:
- 3,456
- Last Active:
Feb 13 2013 07:28 AM- Currently:
- Offline
Previous Fields
- Country:
- DK
- OS Preference:
- Linux
- Favorite Browser:
- Chrome
- Favorite Processor:
- Who Cares
- Favorite Gaming Platform:
- PC
- Your Car:
- Who Cares
- Dream Kudos:
- 50
Posts I've Made
-
In Topic: Linked list within a linked list
Posted 8 Feb 2013
Ah, fair enough. Heh, I'm still mostly using Python 2.
Anyway, I'd actually suggest defining __lt__ for the linked list, rather than the node. For instance, you could compare the lengths:
#A linked list class class SingleSortedLinkedList : #constructor def __init__ (self) : self._size = 0 self._head = None # ... # Compare linked lists by size. def __lt__(self,other): return len(self) < len(other) -
In Topic: Linked list within a linked list
Posted 8 Feb 2013
Well... Simply make an empty linked list, and then insert linked lists in it.
outer_list = SingleSortedLinkedList() inner_list1 = SingleSortedLinkedList() inner_list2 = SingleSortedLinkedList() outer_list.insert(inner_list1) outer_list.insert(inner_list2)
Of course, when your linked list is sorted, you'll need to make it so that linked lists can be compared too (otherwise, how will you know where to insert?). This can be done by overriding the __cmp__ method. How you want to compare them is up to you, of course. -
In Topic: splitting up a string
Posted 29 Jan 2013
I believe the #\ is just Lisps way of saying "this is a char". Like, if it was just (h e l l o), how would you know if h was a char or an atom? -
In Topic: Guessing game getting while loop keeps repeating.
Posted 19 Jan 2013
What darek9576 said - or I'll just tell you, cause it's not a long explanation. break breaks out of loops. There, that's it. So you just put "break" in your code, wherever you want to exit the loop. Like this:
import random while True: print("I'm stuck in a loop!") if random.randrange(0,10) == 4: break print("Yay, I got out of the loop") -
In Topic: convert a fraction to a floating point number
Posted 17 Jan 2013
NecroWinter, on 17 January 2013 - 08:08 PM, said:I didnt even know that you can do datatypes like this, but then again, its like my second day and everything ive done so far has been on a chalk board
I can thoroughly recommend getting an interpreter and typing stuff in to see what happens.
e: Actually, here ya go.
My Information
- Member Title:
- D.I.C Regular
- Age:
- 20 years old
- Birthday:
- February 10, 1993
- Gender:
-
- Interests:
- Programming, reading (fantasy books), writing, music.
- Programming Languages:
-
Know pretty well:
Python
C#
PHP
SML
Java
Processing
Learning:
Haskell
Know a bit of:
Perl
C++
C
Lua
Common Lisp
Javascript
Contact Information
- E-mail:
- Private
Friends
|
|


Find Topics
Find Posts
View Reputation Given

|
Comments
raghav.naganathan
20 Nov 2012 - 06:26Tayacan
20 Nov 2012 - 02:30raghav.naganathan
20 Nov 2012 - 02:25