Subscribe to MentalFloss Minutes        RSS Feed
- - - - -

Complex Logic And Matrices

Icon Leave Comment
So, let's say that you have some problem that involves pretty complex logic, and only two parameters. Instead of writing a bunch of if statements, you can construct an output matrix, and fetch the values that way. For an example, let's mix some paint.

We have our colors: Red, Yellow, Blue.
Red + Yellow = Orange
Red + Blue = Purple
- - - - -

C++ Enum Flip Flop OR Junk Fields?

Icon Leave Comment
Disclaimer: This is probably bad code, but I came across this in trying to solve a problem, and I want to share. Feel free to offer suggestions for improvement.

- - - - -

Logic Exploration

Icon Leave Comment
I want to talk a bit about the various ways of manipulating logic for potentially more readable code.

Let's consider a problem:

You are to test two fruits (APPLE, BANANA, LEMON, LIME) to report on them. There are two conditions:

  • ...
- - - - -

Big IF Or List?

Icon 1 Comments
Let's create a contrived example where the user has selected from an assortment of food. If the user selects a fruit, we want to say "Don't forget to eat your vegetables.", and if they select a vegetable, we'll say "Remember, an apple a day keeps the doctor away."

We might have some such enumeration:

- - - - -

Know Your Requirements

Icon Leave Comment
From my experience in an academic setting, project requirements can often be poorly defined. It is up to you to take the initiative, and clarify every vague notion about the project. It's best to get it in writing via email (just like in the workplace), so that you can reference it in the event of miscommunication.

I recently had to implement...
- - - - -


Icon Leave Comment
For this post we shall consider Java, but it will apply equally well to C++.

Knowing what loop to use for a given situation is an important skill. There are many options, and picking the right one can be confusing at first.

for(type var_name = value; condition; increment)...
- - - - -

I/O Redirect Tutorial

Icon Leave Comment
You might be interested in reading https://www.dreaminc...75-io-redirect/ which explains the I/O redirect option available in developing text-based software (command line).
- - - - -

Source Control

Icon Leave Comment
If you're developing projects, you should be using source control.

Now, people really push github, but I am a much bigger fan of bitbucket because you can have private repos for free. This isn't something github offers.

Plus, bitbucket (technically Atlassian) has a pretty awesome GUI for git called SoureTree. The OAuth is a little wacky,...
- - - - -

C++ Set Exploration

Icon Leave Comment
This entry is just a slow walk through getting familiar with sets.

g++ -std=c++11 -o demo


Getting Started

Let's just get started with some boilerplate:

- - - - -

Comma Separated Lists

Icon Leave Comment
One thing that I have never really properly gotten a handle on is creating comma separated lists of items from a collection. The issue is that the last entry will print a comma: 1, 2, 3, for example. In the past, I would do all kinds of weird code gymnastics to ensure that trailing comma doesn't print, but today I found a wonderful entry on ...

  • (2 Pages)
  • +
  • 1
  • 2

May 2021

16 171819202122


    Recent Entries

    Recent Comments

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)