[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-apl] Slow Macros?
From: |
Christian Robert |
Subject: |
[Bug-apl] Slow Macros? |
Date: |
Fri, 17 Jun 2016 00:29:12 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
⎕pw←1000
df
Freq ╔═══════════════════════╗
║z←Freq m;c ║
║z←⌈/,m ║
║c←z⍴0 ║
║⊣ {c[⍵]←c[⍵]+1}⍤0 ⊢ m ║
║z←⍉(2,z)⍴(⍳z),c ║
╚═══════════════════════╝
Loto ╔════════════════════════════════════════════╗
║z←n Loto x;y;⎕io ║
║⎕io←1 ◊(x y)←x ║
║z←{⍵[⍋⍵;]} {(⊂⍋⍵)⌷⍵}⍤1 ⊢ {x?y⊣⍵}⍤1 ⊢ (n,x)⍴0║
╚════════════════════════════════════════════╝
Randomize ╔═══════════════════════════╗
║Randomize ;fd ║
║fd ← ⎕fio[3] '/dev/urandom'║
║⎕rl←(7⍴256)⊥7 ⎕fio[41] fd ║
║⊣ ⎕fio[4] fd ║
╚═══════════════════════════╝
time ╔══════════════════════╗
║z←time cmd;start;stop ║
║start←⎕fio ¯1 ║
║⊣ ⍎cmd ║
║stop←⎕fio ¯1 ║
║z←(stop-start)÷⎕fio ¯2║
╚══════════════════════╝
time 'r←10000 Loto 6 49'
9.009529247
time 'r←Freq 10000 Loto 6 49'
40.7652658
⍝ I did it for 1,000,000 and pretty sure got the result within 2 minutes
*before* *macros*.
my 2 more cents,
Xtian.
- [Bug-apl] Slow Macros?,
Christian Robert <=