An email exchange : -------- Forwarded Message
--------
https://www.r-bloggers.com/2023/07/array-languages-r-vs-apl/ Avi from Avi
Gross , a fellow very long term investor in
a ` smart glass company " in
development " about as long as CoSy
, triggered my following the
link he mentioned , eventually to Conor Hoekstra's APL vs BQN vs J vs Q vs NumPy vs
Julia vs R prompting the email below which ended up not getting
sent until now :
Conor , While 4th.CoSy is still only my creation , the product of an adult life in APL , evolved and simplified thru K , as an open vocabulary in Forth , it is at the same level of expressive power as the languages you demonstrate but far simpler being Forth RPN -- and radically more flexible being open code all the way to the ` silicon . Chuck Moore's simple use of whitespace as the prime delimiter is an unappreciated brilliance . Here's a rather complete answer to Avi's question which in r-bloggers is : Find the GCD (greatest common divisor) of the smallest and largest numbers in an array and the solution given in Dyalog APL is ⌈/∨⌊/ I believe ` or , ∨ , was extended to also be gcd after I split with traditional APL following Arthur Whitney into K because of its greater simplicity and transparency of structure . Thus CoSy is purely lists of lists . In fact , at the Forth ( hardware ) level the 3 cell header of a CoSy object is simply `( Type Count refCount )` . Thus it intrinsically follows your " Leading Axis " notion . I wasn't sure whether I had implemented gcd in 4th.CoSy so I checked old K.CoSy . This is the definition I used there : gcdIt works on whole lists . When I examine it , it's not terribly efficient . I see that I do have a gcd in the current https://cosy.com/4thCoSy/Code/CoSy/math.f script : : _gcd ( a b -- c) | Jack Browns recursive greatest common divisor | raw ForthBrown's algorithm looks pretty efficient . I don't think the recursion could ever go very deep . Here are the definitions and the x86 for mod and /mod which get called . `( mod /mod )` { dup Help $
See ,L } 'm One of CoSy's
brilliances is that all indexing is modulo . This subsumes such notions
as scalar extension and eliminates all length errors . Another brilliance of Forth is that the single quote , ' , returns the address of the next word , even if its a verb . Thus defining verbs which take both nouns and verbs as arguments ( I like Iverson & Hui's use of adverb for such words ) is trivial . For instance , the phrase in ' gcd above ' >_ on2applies >_ : >_ ( disclose non-nested and free if 0 refs ) dup 0 i@ swap ref0del ;to each of the top 2 CoSy level stack items to get the raw numbers the Forth level _gcd needs . Anyway , here's an answer to the original problem i( 18 24 32 0 )i >t0Conor , I think you can see that CoSy , immature and in need of more heads as it is , is on a level comparable to those other array languages , but far simpler -- and being simply a vocabulary in open Forth , is unmatched in flexibility . CoSy as it stands is just a starting point -- a bridge between brilliances of Iverson and Moore . All the best , Bob A ps ( continuing watching your vid
) | 20230708.0039 | :
Your example of Q , shows it is far more prolix than the K it evolved from after it was clear working with the Whitneys was a dead end and I had to figure out how to roll my own APL in Forth was my only path to what , since I learned of Forth 40 years ago , I saw was possible . pps : I really should do the problem in your vid . : Imat >a i1 i0 cL a@ i1 +i fill a> 2 _take take ; | function ( verb ) to create Identity matricesppps : | 0201 | I strongly recommend anyone watching Conor's not miss the end , the C++ approach . Add
CoSy
to your talents , and your talents to CoSy , A
Fresh Paradigm in
programming language and interface .
See αlphas
When all else
fails REALITY prevails .
Check the Daily
Blog for more , and links on these and other topics .
Coming : premium daily Blog updates : winnowed links to news , commentary & tek If you are running CoSy, the ` Job is downloadable at https://cosy.com/y23/blog.csy giving you all the tools for searching , extracting , etc that the CoSy vocabulary provides .
|