Tayacan's Profile User Rating: -----

Reputation: 145 Stalwart
Group:
Contributors
Active Posts:
275 (0.2 per day)
Joined:
18-January 11
Profile Views:
6,529
Last Active:
User is offline 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
Icon   Tayacan has not set their status

Posts I've Made

  1. 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)
    
    
  2. 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.
  3. 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?
  4. 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")
    
    
  5. In Topic: convert a fraction to a floating point number

    Posted 17 Jan 2013

    View PostNecroWinter, 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:
21 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

Comments

Page 1 of 1
  1. Photo

    raghav.naganathan Icon

    20 Nov 2012 - 06:26
    Most welcome :)
  2. Photo

    Tayacan Icon

    20 Nov 2012 - 02:30
    That's deep, man... Thanks.
  3. Photo

    raghav.naganathan Icon

    20 Nov 2012 - 02:25
    Dude...before your rep changes, I would like to tell you that it(81) is a perfect square :)Cheers :)
Page 1 of 1