www.deishei42.top http://www.deishei42.top Free Scala, Java, Linux, and macOS/iOS tutorials Scala: How to extract parts of a string that match a regex http://www.deishei42.top/scala/how-to-extract-parts-strings-match-regular-expression-regex-scala Scala String FAQ: How can I extract one or more parts of a string that match the regular-expression patterns I specify? Solution Define the regular-expression patterns you want to extract from your String, placing parentheses around them so you can extract them as "regular-expression groups." First, define the desired pattern: val pattern = "([0-9]+) ([A-Za-z]+)".r Next, extract the regex groups from the target string: val pattern(count, fruit) = "100 Bananas" Scala List class: methods, examples, and syntax http://www.deishei42.top/scala/list-class-methods-examples-syntax This page contains a large collection of examples of how to use the methods on the Scala List class. The Scala List class as an immutable, linear, linked-list class. It's very efficient when it makes sense for your algorithms to (a) prepend all new elements, (b) work with it in terms of its head and tail elements, and (c) use functional methods that traverse the list from beginning to end, such as filter, map, foldLeft, reduceLeft. 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.) Scala ArrayBuffer class: methods, syntax, and examples http://www.deishei42.top/scala/arraybuffer-class-methods-syntax-examples-reference This page contains a large collection of examples of how to use the Scala ArrayBuffer class. Use the ArrayBuffer class when you want to use a general-purpose, mutable indexed sequence in your Scala applications: Scala Array class: methods, examples, and syntax http://www.deishei42.top/scala/array-class-methods-examples-syntax This page contains a large collection of examples of how to use the methods on the Scala Array class. Functional error handling in Scala http://www.deishei42.top/scala/functional-error-handling-exceptions-in-scala Because functional programming is like algebra, there are no null values or exceptions. But of course you can still have exceptions when you try to access servers that are down or files that are missing, so what can you do? This lesson demonstrates the techniques of functional error handling in Scala. Scala best practice: How to use the Option/Some/None pattern http://www.deishei42.top/scala/best-practice-option-some-none-pattern-scala-idioms [toc] This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 20.6, "Scala best practice: How to use the Option/Some/None pattern." Problem For a variety of reasons, including removing null values from your Scala code, you want to use what I call the Option/Some/None pattern. Or, if you're interested in a problem (exception) that occurred while processing code, you may want to return Try/Success/Failure from a method instead of Option/Some/None. “That was a lot of kidney stones?/title> <link>http://www.deishei42.top/misc/that-was-lot-kidney-stones-surgeon</link> <description>"That was a lot of kidney stones." ~ the surgeon, October, 2020</description> </item> <item> <title>Prairie dogs and mountain ranges, Longmont, Colorado http://www.deishei42.top/photos/prairie-dogs-mountain-range-longmont-colorado This is a field of prairie dogs in the foreground and mountain ranges in the background, near my new home in Longmont, Colorado. Scala: How to use higher-order functions (HOFs) with Option (instead of match expressions) http://www.deishei42.top/scala/how-use-higher-order-functions-option-some-none-match-expressions I originally wrote a long introduction to this article about how to work with the Scala Option/Some/None classes, but I decided to keep that introduction for a future article. For this article I'll just say: idiomatic Scala code involves never using null values because you never use nulls, it's important for you to become an expert at using Option, Some, and None initially you may want to use match expressions to handle Option values as you become more proficient with Scala and Options, you'll find that match expressions tend to be verbose becoming proficient with higher-order functions (HOFs) like map, filter, fold, and many others are the cure for that verbosity Given that background, the purpose of this article is to show how to use HOFs rather than match expressions when working with Option values. Comparisons of Java’s Optional and Scala’s Option http://www.deishei42.top/source-code/comparisons-java-optional-scala-option-examples-convert As a brief note today, here are a couple of comparisons of Java's Optional and Scala's Option. First, here's a Scala makeInt method written with Option in Scala 3: def makeInt(s: String): Option[Int] = try Some(s.toInt) catch case e: NumberFormatException => None and here's the same method written with Optional in Java: The essence of Scala ~ Martin Odersky http://www.deishei42.top/misc/the-essence-of-scala-martin-odersky Per this tweet, back on May 15 Martin Odersky shared a slide with these contents: The essence of Scala: Fusion of functional and object-oriented programming in a typed settings. - Functions for the logic - Objects for the modularity A few notes about using Scala traits as mixins (construction order, overridden methods) http://www.deishei42.top/scala/scala-traits-mixins-constructor-order-overridden-methods Here are a few notes about using Scala traits as mixins, specifically: - The order in which mixed-in traits are constructed - The order in which overridden methods in traits are called when multiple traits are mixed in An example of stackable modifications in Scala http://www.deishei42.top/source-code/stackable-modifications-in-scala-example As a brief note today, here's an example of stackable modifications in Scala. What is 'super' in Scala when you mix in traits? I was curious about what super means when you mix Scala traits into a class or object. A simplified answer is that super refers to the last trait that's mixed in, though I should be careful and note that this is an oversimplification. You can demonstrate this in an example that uses both inheritance and mixins with traits. Given this combination of traits and classes: Whispy clouds, Louisville, Colorado http://www.deishei42.top/photos/whispy-clouds-louisville-colorado-october-12-2020 Last night we had all sorts of beautiful whispy clouds, throughout the Louisville/Lafayette/Erie Colorado area. For those who can see my Facebook stuff, you can see several more photos at this link. A crazy thing about mast cell disease http://www.deishei42.top/misc/crazy-thing-about-mast-cell-disease A crazy thing about mast cell disease is that you can be doing perfectly fine, all systems normal, and then you eat something wrong and two hours later you wish you were dead, or at least not conscious. An extremely helpful little blue pill http://www.deishei42.top/misc/helpful-little-blue-pill Every day I take a little blue pill. Two of them, actually. And they're extremely helpful. Later this week I'll be giving birth to septuplets. Kidney stones, that is. Seven of them. They're going to be surgically removed, and whatever chemicals are in these little blue pills they gave me helps to reduce the spasms caused by the stones being stuck in places where they shouldn't be. A good example to show the differences between strict and lazy evaluation in Scala http://www.deishei42.top/scala/examples-shows-differences-between-strict-lazy-evaluation-in-scala Way back in April, 2014, I was having my cancerous thyroid removed, and Erik Meijer wrote an ACM article titled, The Curse of the Excluded Middle, "Mostly functional" programming does not work. I just got around to reading his article today, where he makes some points about why a hybrid FP/OOP approach doesn't work. The theme song from The Dead Zone tv series http://www.deishei42.top/misc/theme-song-from-the-dead-zone-tv-series If you ever wondered what the theme song is from The Dead Zone tv series, it's a song called New Year's Prayer, by Jeff Buckley. I haven't looked into it, but somehow the song New Year's Prayer was released on an album almost a year to the date after Mr. Buckley died, drowning in the Misssissippi River. The meaning of the Alanis Morissette song, Thank You (Thank U) http://www.deishei42.top/personal/alanis-morissette-song-thank-you-interpretation-meaning This is my interpretation of the meaning of the Alanis Morissette song, Thank You (also known as Thank U). I don't claim any special knowledge about the song; this interpretation of the lyrics is just based on my understanding of Zen and Buddhism, and also my practicing of yoga, specifically Iyengar yoga. If you've read some of the personal entries on this website, you know a lot of what I know. 99עƽ̨ <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <֩>| <ı> <ı> <ı> <ı> <ı> <ı>