APL + Game of Life = ❤️
Vložit
- čas přidán 29. 06. 2024
- The famous Conway's Game of Life in APL!
Conway's Game of Life Wiki: en.wikipedia.org/wiki/Conway%...
Original John Scholes video: • Conway's Game Of Life ...
Dyalog APL Download: www.dyalog.com/
Dyalog RIDE Download: github.com/Dyalog/ride
Github Code: github.com/codereport/katas/b...
Follow me on Github: github.com/codereport
Follow me on Twitter: / code_report
Follow me on LinkedIn: / codereport - Věda a technologie
I have no clue what's going on in APL, but it looks cool.
All I can say is that you're not alone
I know nothing about APL, when I saw it for the first time a couple of days back it seemed incredibly alien. However, the procedural approach to explaining the implementation in this video made it make a lot more sense to me, intuitively. Nice job!
APL is after all the ultimate language. Writing complex programs in just one line of code is rather remarkable.
Back in the early 80s, I was a tester for an APL interpreter. This brings back a lot of memories. We were able to put the iteration and the display into one line (although it was quite a bit longer than what you had). Thank you very much for this.
I really appreciate seeing new APL videos. Thanks Connor.
Thanks :)
0:00 welcome to a code_report video, my name is conor and today we're reading the necronomicon and how to make a demonic summoning circle
oh man, that was my project in the first year of computer science, can't say it was easy. the voices still haunt me to this day
Rest in peace John Conway
I tried Haskell and Lisp, took a long time to choose between them, both are very tasty. But when I saw APL, I realized that this is the love of a lifetime. I've been studying Gilman and Rose's book for six months now, and I haven't even reached the end of it. I used to pride myself on learning languages fast! At the age of 6, I started programming in Sinclair BASIC. I was considered a child prodigy. It would have been better if I had met APL then, I would have been more modest. What a pity for all the years spent in the darkness of ignorance! Maybe you can give me some advice, can't you?
How about doing a longer video about solving some more complex problem so we can see how APL code scales?
Such an awesome video, amazing work, I love the APL trend recently. This is so neat.
Excellent video - love your work and am intrigued to find out more about APL now
wtf, normally game of life is kinda trivial, but programmed ins APL resembles me the universe creation in some sort of language we still dont understand, its weird and wholesome... wordless
I am FASCINATED in APL, even following your APL vidoes.
Always love seeing some APL :).
Amazing, awesome content !!!!
Great videos. I saw one of your videos by accident, and then kept watching almost all your videos about APL. You're making me interested in this language! I was working on a program that needed topological sorting recently, and I had to think about different ways of implementing it. I just searched for examples of topological sorting in APL, and it's crazy short! It's too sophisticated for me to understand at this point, but I'd love it if someone like you explains it :) In case you're looking for ideas for your future videos.
You're hooked. You can try Q, K, even J. But you'll get back to the symbolic high. ;-)
Actually, this one’s not that hard to understand because the algorithm is straightforward. The APL code for sudoku is much harder, because the algorithm there is non-trivial.
I started learning APL last weekend and was actually able to understand what's happening.
This makes it seem like APL would be pretty good for image processing via convolution matrices and stuff like that
that's so amazing
Thanks!!!
Love your channel! I have also listened to some ADSP podcasts, love them too! Also, I started learning Haskell (so far I like it) and I would like a guide/tutorial for it. Maybe you have some good resources?
When I learned Haskell I used: www.edx.org/course/introduction-to-functional-programming & book.realworldhaskell.org/
@@code_report Thanks! And what text editor/ide do you use to write code in Haskell?
@@Luj8n I usually just type up solutions in GHCI if it is simple. Otherwise I use VS Code.
Wow ...👏👏👏
This looks like something invented by aliens...
I followed each step but reading the finished expressions are baffling. I'm gonna have to learn this.
WARNING: APL is highly addictive. Use at your own risk.
What font are you using here? It looks amazing
At about 4:40 into your video, you say that the middle element is a "no-op". It's actually an identity, because it DID generate the middle result. Mr. Pedantic
Ur lifeInit code helped me to write a password Generator
wow... APL is beautiful
I have to wonder why a 50% starting map (50% 1's) immediately degrades to about 25% 1's. I guess that's because "3 or 4" constitutes 25% of the numbers from 1 to 8. However it later degrades to 10% 1's. I wonder what the steady state percentage would be in an infinite map.
I want to see this in J!
I hope my question is not super redundant, but what editor do you use when programming on APL? :)
Also, why APL and not BQN, or some other newer variant?
I like your videos :))
For APL I use RIDE: github.com/Dyalog/ride
For BQN I use: bqnpad.mechanize.systems/ or mlochbaum.github.io/BQN/try.html
I am learning APL, J and BQN all at the same time. Probably BQN is my favorite. I just don't know it as well as APL at the moment.
Emacs has a pretty nice APL mode too, including REPL support (at least for GNU APL, never tried with Dyalog). It also has an input mode for the APL glyphs (C-\ APL-Z ret) by prefixing them with . and then pressing the correct key for your symbol afterwards. It comes with an overview of which glyph is on which key after the prefix too.
Mic and the keyboard, are they on the same surface?
Your videos make me interested in APL/J. Is there a reason to choose APL over J? From the tiny bits I've read, J seems like a strict improvement.
At the moment, I find APL more beautiful. However, you are correct that J is a superset of the ideas/genius in APL. I am learning both.
@@code_report I'd love to see your J version of this same video
I learned J but haven't learned APL. I found this video to be intelligible from my J experience though, so there's a decent amount of crossover. It might be worth learning J first purely on the grounds that it's more approachable and then use that understanding to go back and learn APL if you want.
I keep getting indexing error on the last function. any idea why that may be?
How to have a library of pattern so to select a few and let it run in the map I wonder? Glider …
You're telling me that with all it's glyphs and esoteric symbols APL still wont use & for and or || for or?
APL is based on Ken Iverson's mathematical symbols, not a typewriter. He used Greek letters, as well as special overstriked characters from an IBM typeball made especially for APL.
Do it again in Uiua
Yoo enchanting table language
How to set up Dyalog?
3:44 that's a rotate
(sorry, couldn't resist)
Also, isn't this a simplification of the rules? Apparently you are counting the center cell as neighbour (which might be fine) and also you are only considering the cases with 3 and 4 neighbors and unless I'm mistaken the original game of life had slightly more involved rules. (Not a criticism of your nice work, just a comment).
These rules are equivalent to the original rules.
The original rules as taken from wikipedia are:
- Any live cell with two or three live neighbours survives.
- Any dead cell with three live neighbours becomes a live cell.
- All other live cells die in the next generation. Similarly, all other dead cells stay dead.
Condition for a cell to be alive:
- Already alive with 2 or 3 live neighbours
- Dead with three live neighbours
Considering itself as a neighbour the condition becomes:
- Already alive with 3 or 4 live neighbours (+1)
- Dead with three live neighbours
Or in other words:
3 live neighbours OR (self and 4 live neighbours)
This is equivalent to the APL expression 1 ⍵∨.∧3 4=...
Hopefully this makes it more clear
@@rorykemp5218 Thanks for the detailed explanation! I didn't try to check the logical equivalence as it looked too different... now it makes sense 😊
@@japedr no problem, glad it makes sense now
I tried running this in RIDE but the line ?2⍴⍨1 2×4 prints random 1s & 2s not !s & 0s. Is there something I'm missing like a configuration for RIDE. New user btw, sorry.
You need to set quad IO to zero. Run: ⎕IO ← 0
@@code_report thanks, awesome. Can I also ask why this needs to be changed, what is actually occurring (philosophically speaking I guess)?
@@oraqlle By default, APL uses arrays that start at index 1. This can be changed however by switching the index origin (⎕IO) to 0.
This index origin affects the roll operator as well so setting IO to 0 will change roll from starting at 1 to 0.
@@loganalt1838 Thanks for the explanation. This got me scratching my head also.
This language makes me laugh :--D
I'm confused; the standard Conway's Game of Life rules are usually expressed as B3/S23, but you seem to have implemented B3/S34, which acts visibly different, and yet your implementation acts just like B3/S23. What am I missing?
When the 9 rotated matrices are sum reduced, this includes the previous board state. Because of this, when he checks for 3 neighbours, this then includes the case of a previously live cell with 2 neighbours.
what ide is this?
I don't know what happens behind the scenes, but duplicating the matrix 8 times makes me sad.
I believe they are not copied in memory eight times. It's a functional language: lazy computing, memoization, and all that.
Fair enough. Is there any way to verify that?
@@korvmakak7727 APL is not lazily evaluated or memoised, so it does indeed create 8 copies. Using wsreq dfns.dyalog.com/n_wsreq.htm it can be seen that applying the rotations on a matrix with a million elements (1000 by 1000) takes just over 1 MB, which is 8 times the size of the matrix considering APL uses 1 bit per boolean.
Interestingly, summing the matrices to create the neighbours count then uses 3 times that, it must not be done in place for some reason.
@@rorykemp5218 Wow. Thanks for the detailed answer!
This looks like some kind of alien language XD
3:42 why is it that (iota)5 gives you a vector that starts at 0 instead of 1?
I guess the same reason why I had to write the lifeInit function as lifeInit ← { 1 = ? 2 ⍴ ⍨ 1 2 × ⍵ }
Sorry... but just got interest in APL and I'm starting to learn (mostly watching your videos)
By default, APL sets indexing to start at 1, but you can change this by using ⎕IO ← 0
I believe Dyalog's default indexing starts at one. To get the behavior in this video you need to run ⎕IO←0
Thank you very much for the information!
Commute? 🥴
guys this is what other feels when we code in python. Good way to insure our jobs. no one can fire you.
I have written code for years.
legitimately have no clue any of this was.
Some how game of life.
Ф
any fp language can do this because of referential transparency
This language looks so cursed
I disagree with the assertion that four live neighbors results in the home cell being brought to life.
Also, I learned APL as my first language, back in 1973, and my work in cellular automata is very well known. See the papers titled Computational Ontogeny
This implementation seems to behave exactly right, with gliders and everything.
I don't know if that would be the case if he used a different ruleset..
@@jessevos3986 See Golly. Create a pattern with a home cell in the middle, and four neighbors, one at each corner of a neighborhood that is 3 by 3 cells in size. I will put my faith into Golly, which is the premier cellular automata software, rather than your assertions.
Just so you know, I learned APL at Golden West College and Orange Coast College, from such luminaries as John Clark (check his history).
If these admonitions are not good enough, then please refer the the original publication of John Horton Conway's model, as published in (as I recall) the October 1970 issue of Scientific American magazine.
@@vNCAwizard You did not understand what I said.
Also, please think about something yourself first, instead of blindly believing what anyone says (they could have made a mistake), or what you think is right (it is possible to misremember), or what some program says (you could have configured, or interpreted it incorrectly).
Consider what evidence reality presents you (the implementation in the video behaving exactly how it should) and compare it to your beliefs (the implementation in the video is incorrect), after that, you can start figuring out exactly where the disconnect is.
Unless I am completely misunderstanding what you're trying to say, which is possible, in which case I excuse myself for coming across rather demeaning.
@@jessevos3986 Try Golly before you assert that four on cells result in creation. I have you nailed. Try Golly. Then review your assertions in prior videos. I don't forget very much.
Are you some kind of fool ?
Mo bamba
This language is disgusting
Great video, and explanation! But when I copied your code in dyalog APL It didn't work. I got the message 'INDEX ERROR'. You must first write ⎕IO ← 0 and put the first element of a list as zero. If you type 0⊃ 'abcd' you must have 'a'