# Dan Baronet

(Redirected from APLtrainer)
Daniel Baronet (far left) at IPSA50 reunion

Daniel Baronet (6 May 1956–1 Nov 2016), also known as APLtrainer, was an APL (and later J) programmer since 1976, working for I.P. Sharp Associates in Melbourne, Toronto, Montreal, and Copenhagen, from 1983 to 1988, and for Dyalog Ltd from 2006 until his death.

Baronet was responsible for Dyalog's Simple APL Library Toolkit (SALT) and its framework for user commands (affectionately known as spice), but also worked on many other APL tools through his company Milinta Inc, specialising in the development of free open-source tools to transfer of APL code between dialects.[1] He was a prolific writer and presented at many events.

## The "Dan Baronet special"

Baronet was famous for innovative uses of APL primitives. He's credited with discovering that `b⊥b` or, as he preferred writing it, `⊥⍨b`, counts the number of trailing ones in the Boolean vector `b`:[2]

`⊥` (Decode) performs base conversion. If the left argument is a vector, it performs mixed base conversion.

For a base vector ${\displaystyle b=b_{n},\cdots ,b_{0}}$ and a digit vector ${\displaystyle a=a_{n},\cdots ,a_{0}}$, `b ⊥ a` converts ${\displaystyle a}$ to the mixed base ${\displaystyle b}$, i.e., it computes ${\displaystyle b_{0}\cdots b_{n-1}a_{n}+\cdots +b_{0}b_{1}a_{2}+b_{0}a_{1}+a_{0}}$.

Now, in a monadic context, `⍨` (Commute) causes the function to the left to be called with equal left and right arguments.

So `⊥⍨b` is defined as `b⊥b`, which computes ${\displaystyle a_{0}\cdots a_{n}+\cdots +a_{0}a_{1}a_{2}+a_{0}a_{1}+a_{0}}$, the sum of all cumulative products from the right to the left.

For `k` trailing ones, the `k` rightmost products are `1` and all others are `0`, so their sum is equal to `k`.[3]

## References

1. Rick Procter. Obituary for Daniel Baronet. APL Borealis.
2. Roger Hui. Tribute to Daniel Baronet. DanielBaronet.RIP
3. Stack User "Dennis". Answer in Dyalog APL to Adám Brudzewsky's code golf challenge. Code Golf and Coding Challenges Stack Exchange.
APL community 
Activities ConferencesAdvent of CodeAPL CultivationAPL Meetup (Portuguese) ∙ APL Problem Solving CompetitionAPL SeedsBAA sessionsCode golfDyalog user meetingsDyalog webinarsIverson AwardSharing code
User groups APL Borealis (Canada) ∙ APL et J (France) ∙ APL Germany (terminology) ∙ BAA (UK) ∙ FinnAPL (Finland) ∙ JAPLA (Japan) ∙ SAUG (Switzerland) ∙ SIGAPL (USA) ∙ SwedAPL (Sweden)
People Phil AbramsBrian BeckerBob BerneckyLarry BreedCharles BrennerJim BrownAdám BrudzewskyGitte ChristensenPhilip Van CleavePeter DonnellyDan DyerAdin FalkoffGarth FosterAaron HsuRoger HuiKen IversonMorten KrombergMarshall LochbaumEugene McDonnellJohn McPhersonJon McGrewDonald McIntyreRoger MooreAlex MorrowAlan PerlisAl RoseWilliam RutiserJohn ScholesIan SharpLynne ShawBob SmithGeoff StreeterRoy SykesRaymond TisserandArthur WhitneyClark Wiedmann