How can i eliminate stackoverflow in this script?

Hey guys first i would like to know whether in applescript a single action that is too complex leads to a stackoverflow or a too long script leads to it. I tried delaying scripts to hopefully free memory for a task that would stack overflow the script but it did not work.
I recently built a script that calculates poker odds in the river of the game, the thing that i encountered however is that when i do not omit the line that contains the info sign, I get a stack overflow, it tries to quicksort a list of 2352 numbers.  Is it only this action that makes it stackoverflow? or how can i solve this? I am sorry that the script i left some modules out like rateallcombos but i can add them whenever you request it. 
It really is strange though because quicksort does work when i pass a list that is 10000 items long or so.
Help is appreciated very much thank you in advance
doriver("10-R", "11-R", "12-R", "13-R", "14-R", "3-H", "14-H")
on doriver(pocket1, pocket2, flop1, flop2, flop3, turn, river)
    set total1 to {"1-S", "2-S", "3-S", "4-S", "5-S", "6-S", "7-S", "8-S", "9-S", "10-S", "11-S", "12-S", "13-S", "14-S", "1-H", "2-H", "3-H", "4-H", "5-H", "6-H", "7-H", "8-H", "9-H", "10-H", "11-H", "12-H", "13-H", "14-H", "1-R", "2-R", "3-R", "4-R", "5-R", "6-R", "7-R", "8-R", "9-R", "10-R", "11-R", "12-R", "13-R", "14-R", "1-K", "2-K", "3-K", "4-K", "5-K", "6-K", "7-K", "8-K", "9-K", "10-K", "11-K", "12-K", "13-K", "14-K"}
    set cardlist to {}
    set the end of cardlist to pocket1
    set the end of cardlist to pocket2
    set the end of cardlist to flop1
    set the end of cardlist to flop2
    set the end of cardlist to flop3
    set the end of cardlist to turn
    set the end of cardlist to river
    set highestscore to rateallcombos(pocket1, pocket2, flop1, flop2, flop3, turn, river)
    set total2 to {}
    repeat with i from 1 to count total1
        if {total1's item i} is not in cardlist then set total2's end to total1's item i
    end repeat
    set a to 1
    set b to 2
    set d to 49
    set e to {}
    repeat 2352 times
        if b is equal to d and b is not equal to 50 then
            set a to a + 1
            set b to a + 1
        end if
        if b is not equal to 50 then
            set bas1 to item a of total2
            set bas2 to item b of total2
            set opposcore to rateallcombos(bas1, bas2, flop1, flop2, flop3, turn, river)
            set the end of e to opposcore
            set b to b + 1
            --efficienter want tablecards?
        end if
    end repeat
    return quicksort(e)
    --set bas to comparteitem(opposcore, highestscore)
    set a to quicksort(e)
    --return bas
end doriver
on quicksort(theList)
    --public routine, called from your script
    script bs
        property alist : theList
        on Qsort(leftIndex, rightIndex)
            --private routine called by quickSort.
            --do not call from your script!
            if rightIndex > leftIndex then
                set pivot to ((rightIndex - leftIndex) div 2) + leftIndex
                set newPivot to Qpartition(leftIndex, rightIndex, pivot)
                set theList to Qsort(leftIndex, newPivot - 1)
                set theList to Qsort(newPivot + 1, rightIndex)
            end if
        end Qsort
        on Qpartition(leftIndex, rightIndex, pivot)
            --private routine called by quickSort.
            --do not call from your script!
            set pivotValue to item pivot of bs's alist
            set temp to item pivot of bs's alist
            set item pivot of bs's alist to item rightIndex of bs's alist
            set item rightIndex of bs's alist to temp
            set tempIndex to leftIndex
            repeat with pointer from leftIndex to (rightIndex - 1)
                if item pointer of bs's alist ≤ pivotValue then
                    set temp to item pointer of bs's alist
                    set item pointer of bs's alist to item tempIndex of bs's alist
                    set item tempIndex of bs's alist to temp
                    set tempIndex to tempIndex + 1
                end if
            end repeat
            set temp to item rightIndex of bs's alist
            set item rightIndex of bs's alist to item tempIndex of bs's alist
            set item tempIndex of bs's alist to temp
            return tempIndex
        end Qpartition
    end script
    if length of bs's alist > 1 then bs's Qsort(1, length of bs's alist)
    return bs's alist
end quicksort

Another issue, the sorting is not done correctly when a string contains a number, you must convert it. like this
set cardnumber1 to (text item 1 of card1) as integer -- convert "6" to 6
example :
set e to {"2", "12", "1", "14", "6", "7", "11"}
quicksort(e)
return e ---> {"1", "11", "12", "14", "2", "6", "7"}
Try this
doriver({"10-R", "11-R", "12-R", "13-R", "14-R", "3-H", "14-H"})
on doriver(cardlist)
     set total1 to {"1-S", "2-S", "3-S", "4-S", "5-S", "6-S", "7-S", "8-S", "9-S", "10-S", "11-S", "12-S", "13-S", "14-S", "1-H", "2-H", "3-H", "4-H", "5-H", "6-H", "7-H", "8-H", "9-H", "10-H", "11-H", "12-H", "13-H", "14-H", "1-R", "2-R", "3-R", "4-R", "5-R", "6-R", "7-R", "8-R", "9-R", "10-R", "11-R", "12-R", "13-R", "14-R", "1-K", "2-K", "3-K", "4-K", "5-K", "6-K", "7-K", "8-K", "9-K", "10-K", "11-K", "12-K", "13-K", "14-K"}
     set highestscore to rateallcombos(cardlist)
     set total2 to {}
     set cardlist2 to {"", ""} & items 3 thru -1 of cardlist
     repeat with i from 1 to count total1
          if {total1's item i} is not in cardlist then set total2's end to total1's item i
     end repeat
     set a to 1
     set b to 2
     set d to 49
     set e to {}
     repeat 2352 times
          if b = d and b ≠ 50 then
               set a to a + 1
               set b to a + 1
          end if
          if b ≠ 50 then
               set item 1 of cardlist2 to item a of total2 -- bas1
               set item 2 of cardlist2 to item b of total2 -- bas2
               set opposcore to rateallcombos(cardlist2)
               set end of e to opposcore
               set b to b + 1
               --efficienter want tablecards?
          end if
     end repeat
     quicksort(e)
     return e
end doriver
on quicksort(theList)
     script o
          property cutoff : 10
          property p : theList
          on qsrt(l, r)
               set i to l
               set j to r
               set v to my p's item ((l + r) div 2)
               repeat while (j > i)
                    repeat while ((my p's item i) < v)
                         set i to i + 1
                    end repeat
                    repeat while ((my p's item j) > v)
                         set j to j - 1
                    end repeat
                    if i ≤ j then
                         set w to my p's item i
                         set my p's item i to my p's item j
                         set my p's item j to w
                         set {i, j} to {i + 1, j - 1}
                    end if
               end repeat
               if j - l ≥ cutoff then qsrt(l, j)
               if r - i ≥ cutoff then qsrt(i, r)
          end qsrt
          on isrt(l, r)
               set x to l
               set z to l + cutoff - 1
               if (z > r) then set z to r
               set v to my p's item x
               repeat with y from (x + 1) to z
                    if (my p's item y < v) then set {x, v} to {y, my p's item y}
               end repeat
               tell my p's item l
                    set my p's item l to v
                    set my p's item x to it
               end tell
               set u to my p's item (l + 1)
               repeat with i from (l + 2) to r
                    set v to my p's item i
                    if (v < u) then
                         set my p's item i to u
                         repeat with j from (i - 2) to l by -1
                              if (v < my p's item j) then
                                   set my p's item (j + 1) to my p's item j
                              else
                                   set my p's item (j + 1) to v
                                   exit repeat
                              end if
                         end repeat
                    else
                         set u to v
                    end if
               end repeat
          end isrt
     end script
     set r to (count theList)
     set l to 1
     if (r > 1) then
          if (r - l ≥ o's cutoff) then o's qsrt(l, r)
          o's isrt(l, r)
     end if
end quicksort
on rateallcombos(cardlist)
     set bas to getcombo(21)
     set points to 0
     repeat with i from 1 to 105 by 5 -- repeat 21 times
          --item a of bas,item b of bas,item c of bas,item d of bas,item e of bas
          set card1 to item (item i of bas) of cardlist
          set card2 to item (item (i + 1) of bas) of cardlist
          set card3 to item (item (i + 2) of bas) of cardlist
          set card4 to item (item (i + 3) of bas) of cardlist
          set card5 to item (item (i + 4) of bas) of cardlist
          RANKER({card1, card2, card3, card4, card5})
          tell the result to if it > points then set points to it
     end repeat
     return points
end rateallcombos
on RANKER(cardlist)
     set suitlist to {}
     set AppleScript's text item delimiters to {"-"}
     repeat with i from 1 to (count cardlist)
          set end of suitlist to text item 2 of item i of cardlist
          set item i of cardlist to (text item 1 of item i of cardlist) as integer -- convert string to integer
     end repeat
     quicksort(cardlist)
     set {card1, card2, card3, card4, card5} to cardlist
     set flush to 0
     set straight to 0
     set points to 0
     --check flush
     set char1 to item 1 of suitlist
     if char1 = item 2 of suitlist and char1 = item 3 of suitlist and char1 = item 4 of suitlist and char1 = item 5 of suitlist then
          set flush to 1
     end if
     --straight
     if (card5 - card4) = 1 and (card4 - card3) = 1 and (card3 - card2) = 1 and (card2 - card1) = 1 then
          set straight to 1
          --works now requires testing
     end if
     --royal flush
     if flush = 1 and straight = 1 and (card1 + card2 + card3 + card4 + card5) = 60 then
          (* card1 = 10 and card2 = 11 and card3 = 12 and card4 = 13 and card5 = 14 *)
          set royalflush to 1000
          set points to 1000
          --does not recognize
     else if flush = 1 and straight = 1 then
          -- straight flush
          set straightflush to 900
          set points to 900
     else if flush = 1 then
          --flush
          set points to 600
     else if straight = 1 then
          --straight
          set points to 500
     else if card1 = card2 and card1 = card3 and card1 = card4 or card2 = card3 and card3 = card4 and card4 = card5 then
          --four of a kind
          set fourofakind to 800
          set points to 800
     else if card1 = card2 and card3 = card4 and card3 = card5 or card1 = card2 and card1 = card3 and card4 = card5 then
          --fullhouse
          set fullhouse to 1
          set points to 700
     else if card1 = card2 and card1 = card3 or card2 = card3 and card3 = card4 or card3 = card4 and card3 = card5 then
          --three of a kind
          set threeofakind to 1
          set points to 400
     else if card1 = card2 and card3 = card4 or card1 = card2 and card4 = card5 or card2 = card3 and card4 = card5 then
          --two pair
          set twopair to 300
          set points to 300
     else if card1 = card2 or card2 = card3 or card3 = card4 or card4 = card5 then
          --pair
          set pair to 200
          set points to 200
     else
          --high card
          set highcard to 100
          set points to 100
     end if
     --ch
     (*royal flush=1000
    straight flush=900<=x<1000
    four of a kind=800<=x<900
    full house=700<=x<800
    flush=600<=x<700
    straight=500<=x<600
    three of a kind=400<=x<500
    two pair=300<=x<400
    one pair=200<=x<300
    high card=100<=x<200
     return points
end RANKER
on getcombo(asbak)
     set totalnocard to {1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 3, 4, 3, 5, 3, 6, 3, 7, 4, 5, 4, 6, 4, 7, 5, 6, 5, 7, 6, 7}
     set finallist to {}
     set t to (count totalnocard)
     repeat with i from 1 to t by 2
          set finallist to finallist & getcardcombos({item i of totalnocard, item (i + 1) of totalnocard})
     end repeat
     return finallist
     -- count finallist is 105 dus klopt want 21*5
end getcombo
on getcardcombos(nocards)
     set finallist to {}
     repeat with i from 1 to 7
          set c to contents of i
          if c is not in nocards then set the end of finallist to c
     end repeat
     return finallist
end getcardcombos
You can take my handler on quicksort(theList) to put it in your script, or use my script.

Similar Messages

  • I do not want to enter a passcode every time I open my iPad. How can I eliminate or disable this feature

    I do not want to use enter a passcode every time I open my ipad  ow can I disable this function. Thanks d n ga

    Settings > General > enter passcode > then tap Turn Passcode OFF

  • When syncing my iphone 6 plus, i now get an error that reads, "IP address conflicts with another system or network."  How can i eliminate this error permanently?   Thank you in advance!

    when syncing my iphone 6 plus, i now get an error that reads, "IP address conflicts with another system or network."  How can i eliminate this error permanently?   Thank you in advance!
    This never happened before, however the last couple of months it comes up every time I plug my USB from PC to iphone.

    HyperNova Software,
    Thank you so much.  Because I am very computer illiterate, could you help me on how to get started?  I don't have the slightest on where to get started, the steps to follow, etc.
    Can't thank you enough for your help!

  • I am trying to download video that i purchased from itunes, but everytime i want to resume the process after pausing it, it automatically start the whole downloading process again, how can i eliminate this problem?

    i am trying to download video that i purchased from itunes, but everytime i want to resume the process after pausing it, it automatically start the whole downloading process again, how can i eliminate this problem?

    They don't normally appear in the download screen ... until I attempt to download another movie. Then they just start appearing. If you click edit - a normal movie download has a circle that appears on the left hand side that allows you to select and delete ... these movies don't have that option so you need to find the movie in you list (under movies) and select the download cloud symbol again to stop it downloading ...you may need to do this a number of times before it stops for a while ... or until you try to download a movie then it starts all over again.
    i have logged out of my itunes account. restarted the iPad, removed all movies, restarted the iPad, logged back into my iTunes account and restarted my iPad .... but as soon as I tried to download a single movies ... the other movies started appearing in the downloads again.

  • I have an iMac on OSX 10.7.5 with Safari 6.1.6. Opening Safari produces a popup that cannot be removed, thus disabling everything else. How can I eliminate this?

    I have an iMac on OSX 10.7.5 with Safari 6.1.6. Opening Safari produces a popup that cannot be removed, thus disabling everything else. How can I eliminate this?

    Launch Safari with the Shift key held down. If that doesn't work, temporarily disconnect the computer from the Internet.
    (124400)

  • Im using Duet2 Interface with Garageband 09 when I connect my acoustic guitar to the combi jack I get a buzzing/humming sound how can I eliminate this?

    I'm using Duet 2 Audio Interface with Garageband 09, when I connect my acoustic guitar to the combi jack I get a buzzing/humming sound.  How can I eliminate this?

    do you have any thing plugged into wall power? Audio interface, computer, speakers, amp for the guitar? if so are they all plugged into the same power strip? if so, have you tried another outlet?
    Altertively have you tried a diffrent port on the combo jack? Have you tried a diffrent guitar cable? Have you tried a diffrent guitar or audio input device like a mic? Is the device directly plugged into the combo jack, or is it being routed throughs some thing?

  • HOw can we Call Subroutine in Sap Script?

    HOw can we Call Subroutine in Sap Script?

    Hi
    *You have to call sub routine from script like this.
    /:   PERFORM DATE_FORMAT IN PROGRAM &SY-REPID&
    /:   USING &RM06P-LFDAT&
    /:   USING &PEKKO-LFDAT&
    /:   CHANGING &VALUE_OLD&
    /:   CHANGING &VALUE_NEW&
    /:   ENDPERFORM
    *In print program write code.
    FORM date_format TABLES in_tab STRUCTURE itcsy
    out_tab STRUCTURE itcsy.
      DATA : date TYPE char10.
      DATA : date2 TYPE char10.
      DATA : l_dmbtr TYPE char10.
      READ TABLE in_tab WITH KEY 'RM06P-LFDAT'.
      IF sy-subrc = 0.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE in_tab WITH KEY 'PEKKO-LFDAT'.
      IF sy-subrc = 0.
        l_dmbtr = in_tab-value.
        "Your code goes here
        CLEAR l_dmbtr.
      ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_NEW'.
        IF sy-subrc EQ 0.
            out_tab-value = date2.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
      READ TABLE out_tab WITH KEY 'VALUE_OLD'.
        IF sy-subrc = 0.
            out_tab-value = l_dmbtr.
            MODIFY out_tab INDEX sy-tabix.
        ENDIF.
    ENDFORM.            "DATE_FORMAT

  • How can change the font in the script output and the data grid ?

    How can change the font in the script output and the data grid in Sql Developer?

    You can't easily unless you have the latest version (2.1.1).
    If you do have this version then changing the font in the Tools/Preferences menu under the code editor/fonts section will also change the font of the data grid.
    For details of changing the fonts in an earlier version then see Sue's post below.
    http://sueharper.blogspot.com/2010/03/back-to-basics-changing-font-setting-in.html

  • How can I eliminate error in printing a cd jewel case cover in latest ITunes version?

    How can I eliminate the printing error in Itunes when attempting to print a cd jewel case cover?  I'm using the latest iTunes version. 

    I finally solved this problem after toiling with it for a couple of days.  Solution:  Once you have  burned your CD you must go back into iTunes to your music/playlists and select the playlist you just burned and click file; print and you will  get the mosaics that we have been accustomed to.  I was on hold with  Apple Support when I found this myself.  Yes......!!! Problem solved..for me anyway.  Good luck!
    Scott

  • How can I eliminate (watch) in videos that read "ERROR: DECODE ERROR"?

    Usually when in a web site (like Fox News) & there's a video to watch I can't watch it due to the message "ERROR: DECODE ERROR". How can I eliminate this & watch the video? Thanks for your input.

    Have you tried to reinstall Flash on your system, uninstall from the control panel, then install from get.adobe.com/flashplayer/‎ and try the video again.
    Also see [[Flash 11.3 doesn't load video in Firefox]]

  • How can I eliminate my count

    I had an iPhone5S and an iPod5, someone stoled them so I wanna know how can I eliminate mi count, and if I could lock this gadgets

    Change your password at http://iforgot.apple.com. You can remote lock your devices if you enabled Find my iPhone on those devices. If so, go to http://icloud.com/find to take action.

  • How can I eliminate SPAM !!

    I am getting inundated with SPAM/advertising messages. How can I eliminate this!

    Is this spam email? If it is, Firefox has no email options. If you are accessing email through Firefox it will be a webmail service. If that is the case you can check with the support for the webmail service to see if they offer a spam filter.
    If it is pop-ups, see http://kb.mozillazine.org/Popups_not_blocked

  • How can I eliminate stairsteps between samples in a graph?

    How can I eliminate stairsteps between samples in a graph? I am graphing the input from a fieldpoint AI-100 and I get stairsteps between samples. I'm using Labview 4.1

    Paul,
    It sounds like you are running into the situation where the resolution of the ADC converter is the source of the behavior you see. Your configuration may be set so that a voltage change is not seen between samples, generating multiple points with the same value. If this is the case, the graph you see is correct. It is displaying the points it receives from the FP-AI-100. You can verify this by displaying the graph data in an array, and seeing if some of the adjacent samples show the same value.
    If this is the case, see if you can match the signal range to that of the ADC to take advantage of the resolution available. For example, if you set the range to be 0 to 30 volts, the smallest detectable voltage change would be 7.3 mV (range/gain*2^resolution) bec
    ause the FP-AI-100 has a resolution of 12-bit. You can read up on issues with range and resolution by doing a search on http://www.ni.com using the keywords "range" and "resolution".
    Otherwise you may be able to compensate for this behavior in software, such as running an averaging routine or applying a mathematical formula to the data points.
    Hope this helps!
    Wilbur Shen
    Applications Engineer, Web Support
    National Instruments

  • How can I eliminate frequent messages requesting keychain login?

    How can I eliminate frequent messages requesting keychain login?

    Take a look at this support article and let us know if it helps with your problem.
    http://support.apple.com/kb/HT1631
    The above link was corrected after the original post.

  • HT1920 I was recently asked for account info on an account that used an email address that had been hacked. how can I get rid of this account record or the account itself.

    I was recently asked for a password for an email on the App store. The email was very old and was one that was hacked so I removed it from my email list. Now I have no record of the account, its password or security questions, and obviously I can't receive email on the account. How can I eliminate this account. I may have already divulged ninfo to this address that could get into the hands of a hacker.

    Email size limits are imposed by mail providers, not the operating system.  They usually vary in the 20-25 MB range.
    The limit is for an individual email plus any attachments it may have.  The only way to release that email message is to reduce the size of the attachment if you can do so.  The limitation itself is from your email provider so there isn't anything you can do to change the limit.

Maybe you are looking for

  • T40/Vista: Fn+F5 can't turn Wifi On/Of

    After upgrading to Vista on my T40 (2373-92G) I can't turn the wireless antenna on/of with the Fn-F5 keys. It only toggles the Blutooth on/off. How can I restore this function? /Jan

  • Disabling manual entry for Passwords

    All, I'm customising the tabbed user form for manual creation of users and i would like to know how i can disable the compulsory password fields. The reason for this is that we dont want to have a password for lighhouse accounts as all users when the

  • Bonded Warehouse Inventory Differences

    Hello, I set up Scraping and Inventory differences for Bonded Warehouse, Scrapping and Posting of positive differences to customs warehouse using a customs declaration, but for negative values it does not work. Wnen I try to finalize the Posting of I

  • Finding controlling areas from company codes

    Hi, can any body tell me the way to find the controlling areas given the company codes lke we find the sales org from the company codes using OVX3. Thanks in advance, Ramakrishna.

  • N73 problems connecting to my Fiat Grande Punto

    I am having trouble with the bluetooth handsfree and my Nokia N73. Previously I had the N70 which I had almost no trouble with. I set up a connection, copied across my contacts to the car and since then evertime I started the engine my phone would au