[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-apl] Power Operator (⍣) broken at svn 740 ?
From: |
Christian Robert |
Subject: |
Re: [Bug-apl] Power Operator (⍣) broken at svn 740 ? |
Date: |
Mon, 13 Jun 2016 14:45:08 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
Work like a charm.
address@hidden:/home/xtian] $ apl
______ _ __ __ __ ___ ____ __
/ ____// | / // / / / / | / __ \ / /
/ / __ / |/ // / / / / /| | / /_/ // /
/ /_/ // /| // /_/ / / ___ | / ____// /___
\____//_/ |_/ \____/ /_/ |_|/_/ /_____/
Welcome to GNU APL version 1.5 / 742
Copyright (C) 2008-2016 Dr. Jürgen Sauermann
Banner by FIGlet: www.figlet.org
This program comes with ABSOLUTELY NO WARRANTY;
for details run: apl --gpl.
This program is free software, and you are welcome to redistribute it
according to the GNU Public License (GPL) version 3 or later.
SAVED 2016-06-13 13:55:43 (GMT-4)
)load test
SAVED 2016-06-13 14:33:38 (GMT-4)
df
┌→─────────────────────────────────────────────────────────────────────────────────────────────┐
│f←{3↓ {⍵,+/¯2↑⍵}⍣{↑(↑⍵)≤¯3+⍴⍺ ⊣ ⎕←('debug:') (24⎕cr (↑⍵)≤¯3+⍴⍺) (↑⍵) ('vs')
(¯3+⍴⍺)} ⊢ ⍵, 0 1}│
└──────────────────────────────────────────────────────────────────────────────────────────────┘
┌→───────────────────────┐
│g←{2↓{⍵,+/¯2↑⍵}⍣⍵ ⊢ 0 1}│
└────────────────────────┘
┌→────────────────────┐
│ltrim←{(+/^\' '=⍵)↓⍵}│
└─────────────────────┘
┌→──────────────────┐
│rtrim←{⌽ ltrim ⌽ ⍵}│
└───────────────────┘
┌→───────────────────────┐
│trim←{⌽ ltrim ⌽ ltrim ⍵}│
└────────────────────────┘
┌→─────────────────┐
│vert←{((⍴⍵),1)⍴,⍵}│
└──────────────────┘
f←{3↓ {⍵,+/¯2↑⍵}⍣{(↑⍵)≤¯3+⍴⍺ ⊣ ⎕←('debug:') (24⎕cr (↑⍵)≤¯3+⍴⍺) (↑⍵)
('vs') (¯3+⍴⍺)} ⊢ ⍵, 0 1}
f 10
debug: ┌→┐ 10 vs 1
│0│
└─┘
debug: ┌→┐ 10 vs 2
│0│
└─┘
debug: ┌→┐ 10 vs 3
│0│
└─┘
debug: ┌→┐ 10 vs 4
│0│
└─┘
debug: ┌→┐ 10 vs 5
│0│
└─┘
debug: ┌→┐ 10 vs 6
│0│
└─┘
debug: ┌→┐ 10 vs 7
│0│
└─┘
debug: ┌→┐ 10 vs 8
│0│
└─┘
debug: ┌→┐ 10 vs 9
│0│
└─┘
debug: ┌→┐ 10 vs 10
│1│
└─┘
1 2 3 5 8 13 21 34 55 89
An other simple way to code this (and faster) is:
g←{2↓{⍵,+/¯2↑⍵}⍣⍵ ⊢ 0 1}
g 10
1 2 3 5 8 13 21 34 55 89
Here my "df" function I find usefull to display Lambda functions and also
regular ones.
∇df[⎕]∇
∇
[0] z←df;⎕pw;∆df
[1] ⊣ ⎕fx "z←∆df n" "→('λ'=↑,⎕cr n)/L" "z←n (⎕cr n)" "→0" "L:" "z←n,'←{',(2↓((⎕cr
n)[2;])),'}'"
[2] ⎕pw←1000 ⋄ z←7 ⎕cr ∆df ¨ ((⍴z),1)⍴ z←({⌽(~∧\' '=⌽⍵)/⌽⍵}¨⊂[1+⎕io] ⎕nl 3)~ "df"
"∆df"
∇
Xtian.
On 2016-06-13 14:27, Juergen Sauermann wrote:
Hi,
I see. Fixed in *SVN 742*.
/// Jürgen
On 06/13/2016 05:32 AM, Xiao-Yong Jin wrote:
Hi Jüergen and Christian,
Despite what is in their manual, dyalog seems to treat 1 scalar element vector
as a scalar here,
⎕ML←2
FIB←{ 3↓ {⍵,+/¯2↑⍵}⍣{(↑⍵)≤¯3+⍴⍺ ⊣ ⎕←'debug:' (⍴⍵) 'vs' (⍴¯3+⍴⍺)} ⊢ ⍵, 0 1
}
FIB 12
debug: 3 vs 1
debug: 4 vs 1
debug: 5 vs 1
debug: 6 vs 1
debug: 7 vs 1
debug: 8 vs 1
debug: 9 vs 1
debug: 10 vs 1
debug: 11 vs 1
debug: 12 vs 1
debug: 13 vs 1
debug: 14 vs 1
1 2 3 5 8 13 21 34 55 89 144 233