Thread: multi arrays

    #1
  1. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0

    multi arrays


    i want to have the equvilent of multi dimensional arrays, but for convenience would like to declare them inside each other. how could i do this, so far i tried the following but get an aerror:
    Code:
        decision = {
            late = {
                call = {
                    3 = {
                        'raise': ( 'AA', 'KK', 'QQ', 'JJ', 'TT', 'AK', 'AQ', 'AJ', 'AT', 'KQ', 'KJ', 'QJ', 'JT', 'AKo' ),
                        'call' : ( '77', 'JT', 'T9', '98', 'QT', 'J9', 'KT', 'K9', 'A9', 'A8', 'A7', 'A6', 'A5', 'A4',
                                   'A3', 'A2', 'QJo', 'JTo', 'KJo', 'QTo', 'KTo' )
                        }
                    }
                }
            }
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2005
    Posts
    43
    Rep Power
    0
    ok i think i have it (although are there any better ways?):
    Code:
        decision = {
            'late' : {
                'call' : {
                    3 : {
                        'raise': ( 'AA', 'KK', 'QQ', 'JJ', 'TT', 'AK', 'AQ', 'AJ', 'AT', 'KQ', 'KJ', 'QJ', 'JT', 'AKo' ),
                        'call' : ( '77', 'JT', 'T9', '98', 'QT', 'J9', 'KT', 'K9', 'A9', 'A8', 'A7', 'A6', 'A5', 'A4',
                                   'A3', 'A2', 'QJo', 'JTo', 'KJo', 'QTo', 'KTo' )
                        }
                    }
                }
            }
    I haven't coded with a hangover before - i think this is what being thick is like
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Code:
    decision['late']['call'][3]['raise'][2]
    ... for convenience?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Alternatively you could have a single dictionary with a tuple for the key:
    Code:
    decision = {
            ('late', 'call', 3, 'raise') :  ( 'AA', 'KK', 'QQ', 'JJ', 'TT', 'AK', 'AQ', 'AJ', 'AT', 'KQ', 'KJ', 'QJ', 'JT', 'AKo' ),
            ('late', call', 3, 'call')  : ( '77', 'JT', 'T9', '98', 'QT', 'J9', 'KT', 'K9', 'A9', 'A8', 'A7', 'A6', 'A5', 'A4',
                                   'A3', 'A2', 'QJo', 'JTo', 'KJo', 'QTo', 'KTo' )
            }
    
    
    print decision['late','call',3,'raise'][2]
    Dave
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    588
    Rep Power
    64

    Smile


    Originally Posted by DevCoach
    Alternatively you could have a single dictionary with a tuple for the key:
    Code:
    decision = {
            ('late', 'call', 3, 'raise') :  ( 'AA', 'KK', 'QQ', 'JJ', 'TT', 'AK', 'AQ', 'AJ', 'AT', 'KQ', 'KJ', 'QJ', 'JT', 'AKo' ),
            ('late', call', 3, 'call')  : ( '77', 'JT', 'T9', '98', 'QT', 'J9', 'KT', 'K9', 'A9', 'A8', 'A7', 'A6', 'A5', 'A4',
                                   'A3', 'A2', 'QJo', 'JTo', 'KJo', 'QTo', 'KTo' )
            }
    
    
    print decision['late','call',3,'raise'][2]
    Dave
    Good thinking Dave, but your second call' should be a 'call'

    Comments on this post

    • Yegg` agrees : :)

IMN logo majestic logo threadwatch logo seochat tools logo