I created a vision board many years ago during a retreat, and I have to say, everything on the board came true. I was thinking recently that it would be even more true if I didn’t have health problems for several years, and more recently providing financial support for family members. If it weren’t for those things I’d probably be living in Talkeetna or Palmer, Alaska today, writing more books.
Scala, Java, Unix, MacOS tutorials (page 128)
Table of Contents
- Scala List class introduction
- Notes about the following List examples
- CREATE: Create a new List with initial elements
- CREATE: Create a new List by populating it
- READ: How to access Scala List elements
- UPDATE: How to add (append and prepend) elements to a List
- UPDATE: How to “update” List elements
- DELETE: Filtering methods (how to “remove” elements from a List)
- MORE: Transformer methods
- MORE: Informational and mathematical methods
- MORE: Grouping methods
- MORE: Looping over a List with for and foreach
- A few things you can do with a List of Options
- Scala List summary
This page contains a large collection of examples of how to use the methods on the Scala List class.
Scala List class introduction
The List class is 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.
Summary: This page contains many examples of how to use the methods on the Scala Seq class, including map, filter, foldLeft, reduceLeft, and many more.
Important note about Seq, IndexedSeq, and LinearSeq
As an important note, I use Seq in the following examples to keep things simple, but in your code you should be more precise and use IndexedSeq or LinearSeq where appropriate. As the Seq class Scaladoc states:
Table of Contents
- Vector class introduction
- Notes about the following Vector examples
- CREATE: How to create a Vector with initial elements
- CREATE: Create a new Vector by populating it
- READ: How to access Vector elements
- UPDATE: How to add (append and prepend) elements
- UPDATE: How to “update” Vector elements using its methods
- DELETE: Filtering methods (how to “remove” elements from an Vector)
- MORE: Transformer methods
- MORE: Informational and mathematical methods
- MORE: Grouping methods
- Looping over a Vector with for and foreach
- A few things you can do with a Vector of Options
- Scala Vector summary
This page contains over 170 examples of how to use the Scala Vector class, covering most of the methods that are available on a Vector, including map, filter, foldLeft, reduceLeft, and many more.
Scala Vector class video
As a brief update, if you prefer videos, here is my Scala Vector class training video.
The Scala Vector class
Use the Vector class when you want to use a general-purpose, immutable indexed sequence in your Scala applications:
I have The Dancer Upstairs playing while I work today. I don’t remember how/where/why I saw it the first time, but I remember when I saw it I thought, “That Javier Bardem guy is really good.” Other than the dog scenes, it’s a very good movie.
“Technology is our superpower. Inequality is our kryptonite.”
I’ll add that not caring about the planet we live on is also our kryptonite.
Java Design Patterns FAQ: Can you provide an example of the Factory Pattern in Java?
Sure. In this article we'll look at a small-but-complete example of the Factory Pattern ("Factory Design Pattern") implemented in Java.
I’m not a huge believer in certain types of karma in this world, but Jack Kornfield offers this discussion about karma related to speech, and intention:
“Speech is one area in which karma can be seen in an easy and direct way. For this exercise, resolve to take two or three days to carefully notice the intentions that motivate your speech. Direct your attention to the state of mind that precedes talking, the motivation for your comments, responses, and observations. Try to be particularly aware of whether your speech is even subtly motivated by boredom, concern, irritation, loneliness, compassion, fear, love, competitiveness, greed, or whatever state you observe ... Simply notice the various motivations in the mind and the speech that flows from them.”
“Then, after discovering which motivation is present as you speak, notice the effect of the speech. If there is competitiveness or grasping or pride or irritation behind the speech, what response does it elicit from the world around you? If there is compassion or love, what is the response? If your speech is mindless, as if you were on automatic pilot, what is the response? If there is clarity and concern, how is this received and responded to?”
It brings up an excellent point: What motivates your speech?
If you’re coming to Boulder, Colorado, the TravelBoulder.com website looks like it might be a useful resource.
I don’t know the origin of this “Do not let the behavior of others destroy your inner peace” Dalai Lama - Homer Simpson cartoon, but I like it.
“Wherever you have friends, that’s your country; wherever you receive love, that’s your home.”
~ an old Tibetan saying, as read in The Book of Joy
Today’s mindfulness “lesson of the day” (mostly for myself) is a reminder to keep practicing, even when you don’t feel like it. You don’t get to choose when moments of enlightenment happen, so the best thing you can do is keep practicing so those moments will be possible when the right circumstances (karma?) come into alignment.
What happens is that over time, both the mindfulness and the enlightenment bits change the wrinkles in your brain, change your perspective and attitude, and cleanse the environmental conditioning of whatever happened to get you to this point. With continued practice you evolve (think “metamorphosis”) into a new person over time — this time a person of your own choosing, rather than a person conditioned by where and when you were born and lived.
Namaste. ;)
I just learned about Hanlon’s Razor, which states, “we should not attribute to malice that which is more easily explained by stupidity.” I have often been guilty of the malice assumption, so I found this interesting.
In a related note, Wikipedia’s definition of philosophical razors is also interesting.
Farnam Street blog has a good article, Nine mental models to solve difficult problems.
If you’re interested in metaprogramming with Scala, Scalameta is “a modern metaprogramming library for Scala that supports a wide range of language versions and execution platforms. Originally, Scalameta was founded to become a better macro system for Scala, but over time we shifted focus to developer tools and spun off the new macro system into a separate project.”
If you’re interested in the future of Scala, specifically Scala 3, the official Scala blog has an interesting article titled, Macros: The Plan for Scala 3. A beneficial part of reading at least part of the article is that you can learn a little bit about Tasty, “the high-level interchange format for Scala 3.”
I just bought a bunch of MP3 music files from Amazon, and when I downloaded the zip file they provide onto my Mac, it was a bunch of files in a bunch of subdirectories; not really convenient to work with when you’re trying to import them into iTunes. So I used this Unix find command to move all of the music files from the subdirectories they were scattered in into the root directory that was created when I expanded the zip file:
cd Amazon-Music-Folder
find . -type f -exec mv {} . \;
If you ever need to either copy or move a bunch of files with a single command, I hope this example shows the correct find command syntax for your needs. (If you need to copy the files, use the cp command instead of the mv command.)
There are times when I work on images a lot with Gimp, and then there are times when I don’t work with Gimp for a month or two. When I don’t work with Gimp a lot, I tend to forget about all of the different things I can do with. Therefore, I have created this page as a “Gimp special effects cheat sheet” page to help remind me of all the cool things I can do with Gimp effects.