www.deishei42.top http://www.deishei42.top Free Scala, Java, Linux, and macOS/iOS tutorials Definition of a “foldâ€?in programming http://www.deishei42.top/misc/definition-of-fold-in-computer-programming I was just updating my Scala fold/reduce tutorial, and noticed that I start with this definition of a fold in computer programming from the excellent book, Learn You a Haskell for Great Good: "Folds can be used to implement any function where you traverse a list once, element by element, and then return something based on that. Whenever you want to traverse a list to return something, chances are you want a fold. That's why folds are, along with maps and filters, one of the most useful types of functions in functional programming." That's a great definition because it includes (almost) everything, so I'll add this: You traverse an entire list, once Element by element You apply your own custom algorithm to the elements as you traverse the list In the end, you return a single value based off of that traversal and the application of your algorithm If you're interested in the definition of a fold in computer programming, I hope that's helpful. See my fold/reduce tutorial for many more details. Scala Vector class: method examples and syntax http://www.deishei42.top/scala/vector-class-methods-syntax-examples This page contains a large collection of examples of how to use the Scala Vector class, including most of the methods that are available on a Vector. (Currently over 170 examples.) The notes that became Functional Programming, Simplified http://www.deishei42.top/photos/functional-programming-simplified-notes-2016 Back in 2016 I posted this photo on Facebook with the caption, "The current minefield that may one day grow into a book." Those notes eventually grew into Functional Programming, Simplified. Scala: What do “effectâ€?and “effectfulâ€?mean in functional programming? http://www.deishei42.top/scala/what-effects-effectful-mean-in-functional-programming When you get started with functional programming (FP) a common question you'll have is, "What is an effect in functional programming?" You'll hear advanced FPers use the words effects and effectful, but it can be hard to find a definition of what these terms mean. The secret passion of Steve Jobs (Japanese art) http://www.deishei42.top/photos/secret-passion-steve-jobs-japanese-art I haven't watch all of this video yet, but from what I have seen, it appears that Steve Jobs secret passion was Japanese art. Looking into writing a Scala 3 testing framework http://www.deishei42.top/misc/looking-into-writing-scala-3-testing-framework As a brief note to self, I started looking into writing my own Scala testing framework, mostly because the main current frameworks are not currently available for Scala 3.0-M3. That led me to this Minitest blog post, the Minitest repository, and finally this sbt test-interface repository. It looks like if you want to write your own testing framework to work with sbt, that interface is what you need to implement. I just tested Minitest with Scala 3, and it seems to work, so for now I'm not going any further. But I was happy to find that interface project, because I have often wondered what it would take to write a testing framework to work with sbt. A garbage dumpster in Seward, Alaska http://www.deishei42.top/photos/garbage-dumpster-seward-alaska My favorite garbage dumpster in Seward, Alaska: "Look for moose." The Scala 3 scalac -source 3.1 option http://www.deishei42.top/source-code/scala-3-scalac-source-3.1-option-syntax If you ever need to use the Scala 3 -source option with scalac or the SBT build.sbt file, the correct syntax is: -source:3.1 It's not clear from the scalac help text how the -source option should be used, and I just figured that out in my build.sbt file, which has these scalac options: scalacOptions ++= Seq( "-deprecation", // emit warning and location for usages of deprecated APIs "-explain", // explain errors in more detail "-explain-types", // explain type errors in more detail "-feature", // emit warning and location for usages of features that should be imported explicitly "-indent", // allow significant indentation. "-new-syntax", // require `then` and `do` in control expressions. "-print-lines", // show source code line numbers. "-unchecked", // enable additional warnings where generated code depends on assumptions "-Ykind-projector", // allow `*` as wildcard to be compatible with kind projector "-Xfatal-warnings", // fail the compilation if there are any warnings "-Xmigration", // warn about constructs whose behavior may have changed since version "-source:3.1" ) An example sbt build.sbt file for a Scala 3 (3.0.0-M3) project (including scalacOptions) http://www.deishei42.top/source-code/scala-3-example-build.sbt-file-scalacOptions As a brief note to self, this is an example sbt build.sbt file I just used for a Scala 3 (3.0.0-M3) project, including several scalacOptions: The Soul Game http://www.deishei42.top/personal/the-soul-game-a-spirituality-model [This is a chapter from a currently-unpublished book I'm writing on meditation and mindfulness.] As a spiritual being, one possible way to think of life here on Earth is as a "game" that serves as a training ground for the soul. It's a game like other games, so it has many levels, and they get harder and harder as you progress. So in this case, the better you become at the game of spirituality -- the Soul Game -- the harder the levels become. Scala Array class: methods, examples, and syntax http://www.deishei42.top/scala/array-class-methods-examples-syntax [toc] This page contains dozens of examples that show how to use the methods on the Scala Array class. Scala Array class introduction The Scala Array class is a mutable, indexed, sequential collection. Unlike the Scala ArrayBuffer class, the Array class is only mutable in the sense that its existing elements can be modified; it can't be resized like ArrayBuffer. A moth is a mapmaking creature (and Zen koans) http://www.deishei42.top/misc/moth-is-map-making-creature-zen-koans A moth is a mapmaking creature. When it flies into a candle it's working from an erroneous map. Maybe the moth's map says, "Mating opportunities here." A human is also a mapmaking creature. Everyone operates from a map, and the map is always getting out of date. Life, the territory described by the map, moves quickly. This means that the map drifts away from the territory, eventually becoming more of a historical artifact than a useful guide. When there is a wide gap between the map and current world, the person who made the map feels discomfort. For however long it worked, it was a nice map, and now it doesn't work any more. In this situation, unlike moths, humans have two choices. One is the path of discovery, in which the map is abandoned or redrawn over and over again. The other path is one in which the more doubts you have about a map, the more strongly you insist it's accurate. This is the path that leads the moth into the flame. If you follow this path, you're living by a fiction, an erroneous map ... essentially what you're doing is building a prison cell of non-reality to live in, your own little Alcatraz. It's the job of the koan to take down your prison walls, to undermine your fictions. Then you might discover that you're not really suffering from other people or from circumstances. You're suffering from your maps, your fictions, the prison you yourself have created. A quote from a book titled, Bring Me the Rhinoceros: And Other Zen Koans That Will Save Your Life, by John Tarrant Get the “Functional Programming, Simplifiedâ€?PDF for $10 http://www.deishei42.top/misc/scala-functional-programming-simplified-pdf-discount If you purchased the paperback or Kindle versions of "Functional Programming, Simplified," I now have the ability to offer you a discount on the PDF version of the book. To get the PDF for just $10 -- a 50% discount -- just send a proof of purchase to book-discounts@www.deishei42.top and I'll send you a discount code and URL. Proof of purchase Since the paperback and Kindle versions are only sold through Amazon, "proof of purchase" can be a copy of your Amazon receipt. Please scrub out your credit card information and address before sending me the proof of purchase, I have no interest in that information. This is a manual process, so if I get a lot of responses, turnaround time might be a little slow. The fine print All prices shown are in U.S. currency (USD) Your email address will never be used for anything else except communications related to this offer Functional Programming, Simplified http://www.deishei42.top/scala/functional-programming-simplified-book My book, Functional Programming, Simplified -- 4.5-star rated on Amazon, and their 6th-best selling functional programming book -- is currently on sale in three formats: PDF Format $20 on Gumroad.com Paperback Book Now $34.99 on Amazon Kindle eBook $14.99 on Amazon Cat at a rest area http://www.deishei42.top/photos/cat-at-rest-area-virginia-beach Back around 4:30am on January 13, 2014, I pulled into a rest area in Virginia after staying in Virginia Beach for a while (and experiencing a tornado warning there), and found this cat waiting for me. Creating Scala JavaBeans with the @BeanProperty annotation http://www.deishei42.top/scala/scala-javabeans-beanproperty-annotation Scala JavaBean FAQ: How do I create the Scala equivalent of a JavaBean in Java (a Scala JavaBean)? There are times when you're working with Scala where backwards compatibility with Java and JavaBeans is required. I ran into this recently with the Java Snakeyaml library (see my Scala YAML parsing with Snakeyaml tutorial). Virginia Beach tornado weather http://www.deishei42.top/photos/virginia-beach-tornado-weather It felt like we might have a tornado in Virginia Beach today, with that familiar and unusual low-pressure feeling. At one point it even looked like the ocean water was being pulled up into the sky. ~ January 11, 2014 Tornado warnings and sarcasm tees http://www.deishei42.top/photos/tornado-warning-national-sarcasm-t-shirt-virginia As I walked into the Starbucks today here in Virginia Beach, an alarm went off on my phone saying there was a tornado warning. So I asked the three people working there, "Which is worse, a tornado warning or a watch? I can never remember which is which." So rather than google it, we talked about whether "watch" or "warning" implied more danger, then we talked about some other things while we watched stuff go flying down the street. Never did figure out which is worse, but eventually I got a coffee. Later in the day as I was walking down a street I came across a gift shop that had been blown all over the place by the winds, and found this t-shirt amongst the ruins. ~ January 11, 2014 The chord of love that binds you and me is known to my soul alone http://www.deishei42.top/misc/chord-of-love-binds-you-is-known-to-my-soul-alone "One's agony is assuaged to some extent even by speaking of it, but to whom shall I speak about it? For there is no one who will understand. The reality about the chord of love that binds you and me, dear, is known to my soul alone; and my soul ever abides with you. Know this to be the essence of my love." ~ A god speaking about his love for a devotee in the Ramayana, as seen in the book, Miracle of Love Quotes from Clean Code http://www.deishei42.top/programming/clean-code-quotes-robert-c-martin Back in 2013 I read the book Clean Code by Robert C. Martin, and in an effort to keep that book alive with me a little while longer, I decided to make my own "Cliffs Notes" version of the book on this page. One of my favorite notes from below is that a language named LOGO used the keyword to in the same way that Scala uses def, so a method named double would be defined as to double... instead of def double..., which seems like it would help developers name methods better. 99ŐćČËע˛áƽ̨