bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] Unique far too slow


From: Christian Robert
Subject: [Bug-apl] Unique far too slow
Date: Fri, 16 Sep 2016 23:12:17 -0400
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0


      time "z ← downcase ¨ words readfile 'big.txt'"
7.859168565

      time "s ← sortvs z"
4.423386895

      ⍝ well, read took 8 seconds (over a million words)
      ⍝ sorting the result took 5 seconds

      time "U ← ∪ z"
101.1162267

      ⍝ why does the "∪" operator took so long ? eg: 101  seconds.


pretty sure this can be improved by a factor 2 to 5 times shorter.



my definitions:

  downcase←{ ⎕UCS (32×(⍵≥65)∧⍵≤90)+⍵←⎕UCS ⍵}
  readfile←{⎕fio[26] ⍵}
  sortvs←{⍵[⎕av⍋⊃⍵]}
  words←{(⍵ ∊ ,⎕ucs (65 97)∘.+⎕io-⍨⍳26) ⊂ ⍵}

big.txt is the one used in several reports last 2 weeks.


Xtian.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]