Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CatalogContent:
- 'paths/code-foundations'
---

Functional Programming (FP) is a declarative software development paradigm that encourages constructing programs by composing pure functions and evaluating expressions instead of statements. The functions are isolated and independent of the state of the application.
**Functional programming (FP)** is a declarative software development paradigm that encourages constructing programs by composing pure functions and evaluating expressions instead of statements. The functions are isolated and independent of the state of the application.

In FP, dependencies such as variables or objects needed for a function, are always declared explicitly by passing them into the function as arguments. Any operation inside the function is therefore bound to the arguments passed, instead of depending on global objects or variables. This makes the function:

Expand All @@ -26,12 +26,12 @@ FP helps make code more modular and understandable.

FP revolves around a few fundamental concepts that are important to discern in order to understand what makes it a popular approach to software development.

### First-class entities
### First-Class Entities

In FP, functions are considered to be first-class entities. This means that functions can be:

- Assigned to a variable
- Passed as arguments into other functions
- Assigned to a variable.
- Passed as arguments into other functions.
- Returned from other functions, just as any other data type can.

Higher-order functions are a type of first-class functions, as they can take functions as arguments and/or return a function.
Expand Down
10 changes: 7 additions & 3 deletions content/git/concepts/reset/reset.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ CatalogContent:
- 'learn-git'
---

In Git, the `reset` command is used to change the state of the Git repository or undo commits.
The **`reset`** command is used to change the state of the Git repository or undo commits.

## Syntax
**Note**: This command is ideal for undoing uncommited changes made in a private, local repository. For undoing changes in a public, remote repository, the `revert` command is recommended.

The `git reset` command is run in the [terminal](https://www.codecademy.com/resources/docs/general/terminal) and generally follows this template:
## Syntax

```pseudo
git reset <mode-option> <commit-reference>
```

This is run in the [terminal](https://www.codecademy.com/resources/docs/general/terminal). The `<mode-options>` and `<commit-reference>` are discussed in more detail below.

### Mode Options

The `<mode-options>` refer to how far `reset` will go when rolling back changes to a previous commit, including:
Expand All @@ -44,6 +46,8 @@ The `commit-reference` refers to a commit's unique hash, or save point, that was

`git reset` can be used with either the commit hash or with the `HEAD` keyword, which refers to the commit being viewed on the currently checked-out branch.

Alternatively, a filename can be used in place of the `commit-reference` to undo a `git add` for a file that wasn't meant to be staged for commit.

## Example

This is what the terminal would look like after creating a commit by accident on the `main` branch and running [a `git status` check](https://www.codecademy.com/resources/docs/git/status):
Expand Down
49 changes: 49 additions & 0 deletions content/git/concepts/tag/tag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
Title: 'Tag'
Description: 'Creates, lists, deletes, or verifies a commit marker with a GnuPG tag object attached.'
Subjects:
- 'Bash/Shell'
- 'Developer Tools'
Tags:
- 'Git'
- 'Version Control'
CatalogContent:
- 'learn-the-command-line'
- 'learn-git'
---

The **`tag`** command creates, lists, deletes, or verifies a commit marker with a [GnuPG tag object](https://gnupg.org/) attached. This helps add some semantic meaning to a commit message.

## Syntax

```pseudo
git tag <flags> <tag-name> <commit-reference> <tag-object>
```

The `<flags>` include the following:

| Flag | Description |
| :---------------: | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `-a`/`--annotate` | The tag is annotated but unsigned. |
| `-s`/`--sign` | The tag is annotated and signed with the key of the default email address. |
| `-f`/`--force` | An existing tag is forcibly replaced with a given `<tag-name>`. |
| `-d`/`--delete` | One or more existing tags are deleted by `<tag-name>`. |
| `-v`/`--verify` | One or more existing tags are verified by `<tag-name>`. |
| `-l`/`--list` | All existing tags are listed (same as running just `git tag`). |
| `-m`/`--message` | A message for an existing tag is defined instead of prompted. Multiple `-m` messages can be used, but they will combined as separate paragraphs. |
| `-F`/`--file` | A tag message from an existing file is read from the standard input. |
| `-e`/`--edit` | A tag message made from `-m` or `-F` is edited. |

The `<tag-name>` refers to the tag object for a commit.

The `<commit-reference>` is the commit the tag will be attached to.

The `<tag-object>` is usually the commit that the new tag refers to (defaults to the `HEAD`) pointer.

## Example

The following is a small example of the `tag` command being used to create and annotate an object for the `HEAD` commit pointer:

```shell
git tag -a tag-for-head-pointer
```
35 changes: 22 additions & 13 deletions content/java/concepts/strings/strings.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Title: 'Strings'
Description: 'A String in Java is an object that holds a sequence of characters contained within a pair of double quotes ("). It is not a primitive datatype. Java strings provide a way to store something like a word, sentence, or whole paragraph. They can be any length and can contain letters, numbers, symbols, and spaces. java // Creating a String variable String name = "Codecademy"; // Creating another String variable String address = "575 Broadway #5, New York, NY 10012"'
Description: 'A string in Java is an object that holds a sequence of characters contained within a pair of double quotes (").'
Subjects:
- 'Computer Science'
Tags:
Expand All @@ -12,23 +12,32 @@ CatalogContent:
- 'paths/computer-science'
---

A `String` in Java is an object that holds a sequence of characters contained within a pair of double quotes (`"`). It is not a primitive datatype.
**Strings** in Java are objects that can hold a sequence of characters contained within a pair of double quotes (`"`). It is not a primitive data type.

Java strings provide a way to store something like a word, sentence, or whole paragraph. They can be any length and can contain letters, numbers, symbols, and spaces.
Strings can either be compared by value via method (e.g., [`.equals()`](https://www.codecademy.com/resources/docs/java/strings/equals)) or by reference, or location in memory, (e.g., `==`) via operator.

## Example

Java strings provide a way to store text such as words, sentences, or whole paragraphs. They can be any length and may contain letters, numbers, symbols, and spaces:

```java
// Creating a String variable
String name = "Codecademy";
import java.util.*;

// Creating another String variable
String address = "575 Broadway #5, New York, NY 10012";
```
class StringExample {
public static void main(String[] args) {
// Using a string literal
System.out.println("Codecademy");

To compare `String`s, the `.equals()` method must be used instead of the primitive equality comparator `==`. `.equals()` will compare the values of the strings, while `==` compares the references (location in memory) of the strings.
// Creating a String variable
String address = "575 Broadway #5, New York, NY 10012";
System.out.println(address);
}
}
```

```java
String name = "Bob";
This will output the following:

// The following will print "false" because strings are case-sensitive
System.out.println(name.equals("bob"));
```shell
Codecademy
575 Broadway #5, New York, NY 10012
```
28 changes: 20 additions & 8 deletions content/java/concepts/strings/terms/compareTo/compareTo.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
---
Title: '.compareTo()'
Description: 'Compares two strings lexicographically based on the Unicode value of each character in the string.'
Description: 'Returns 0 if two strings are equal in Unicode value. Otherwise, the lexicographical difference is returned.'
Subjects:
- 'Computer Science'
Tags:
- 'Characters'
- 'Strings'
- 'Methods'
CatalogContent:
- 'learn-java'
- 'paths/computer-science'
---

Compares two strings lexicographically based on the Unicode value of each character in the string.

A value of `0` will be returned if equal to comparison, less than `0` if the string is lexicographically less, and greater than `0` if the string is lexicographically greater.
The **`.compareTo()`** method compares two strings lexicographically based on the Unicode value of each character in the string.

## Syntax

```java
string.compareTo(String str)
```pseudo
stringA.compareTo(stringB);
```

- `str` (required): A string value, the other string to compare to.
Both `stringA` and `stringB` are required in order for the `.compareTo()` method to work properly.

A value of `0` will be returned if the strings are equal. Otherwise, the following will happen:

- A number less than `0` is returned if `stringA` is lexicographically less than `stringB`.
- A number greater than `0` is returned if `stringA` is lexicographically more than `stringB`.

A way to think about this lexicographical evaluation is noting the Unicode values for the following character sets:

| Character Set | Range | Example |
| :-----------: | :------: | -------------------------------------- |
| `1` - `9` | 49 - 57 | `"7".compareTo("3");` -> 55 - 51 = 4 |
| `A` - `Z` | 65 - 90 | `"A".compareTo("B");` -> 65 - 66 = -1 |
| `a` - `z` | 97 - 122 | `"z".compareTo("w");` -> 122 - 119 = 3 |

**Note:** Use `.compareToIgnoreCase()` if you want to compare lexicographically, while not comparing the upper and lower case differences. Use `.equals()` if you want to compare strings without taking into account Unicode values.
**Note:** This method is case-sensitive. The [`.compareToIgnoreCase()`](https://www.codecademy.com/resources/docs/java/strings/compareToIgnoreCase) can be used to ignore upper and lower case differences. Alternatively, the [`.equals()`](https://www.codecademy.com/resources/docs/java/strings/equals) method can used to compare strings without taking Unicode values into account.

## Example 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
---
Title: '.compareToIgnoreCase()'
Description: 'Compares two strings lexicographically based on the Unicode value of each character in the string while ignoring lower case and upper case differences.'
Description: 'Returns 0 if two strings are equal in Unicode value, regardless of character case. Otherwise, the lexicographical difference is returned.'
Subjects:
- 'Computer Science'
Tags:
- 'Characters'
- 'Strings'
- 'Methods'
CatalogContent:
- 'learn-java'
- 'paths/computer-science'
---

Compares two strings lexicographically based on the Unicode value of each character in the string while ignoring lower case and upper case differences.
The **`compareToIgnoreCase()`** method compares two strings lexicographically based on the Unicode value of each character in the string while ignoring lower case and upper case differences.

A value of `0` will be returned if equal to comparison, less than `0` if the string is lexicographically less, and greater than `0` if the string is lexicographically greater.

## Syntax

```java
string.compareToIgnoreCase(String str)
```pseudo
stringA.compareToIgnoreCase(stringB);
```

- `str` (required): A string value, the other string to compare to.
Both `stringA` and `stringB` are required in order for the `.compareTo()` method to work properly.

A value of `0` will be returned if the strings are equal. Otherwise, the following will happen:

- A number less than `0` is returned if `stringA` is lexicographically less than `stringB`.
- A number greater than `0` is returned if `stringA` is lexicographically more than `stringB`.

Through the `CASE_INSENSITIVE_ORDER` field of the `String` class, upper and lower case characters effectively hold the same Unicode value (e.g., "a" - "A" = 0).

**Note:** Use `.compareTo()` if you want to compare while not ignoring the upper and lower case differences. Use `.equals()` if you want to compare strings without taking into account Unicode values.
**Note:** To take case into account, the [`.compareTo()`](https://www.codecademy.com/resources/docs/java/strings/compareTo) method should be used. Alternatively, the [`.equals()`](https://www.codecademy.com/resources/docs/java/strings/equals) method can be used to compare strings without taking Unicode values into account.

## Example 1

Expand Down
50 changes: 50 additions & 0 deletions content/java/concepts/strings/terms/equals/equals.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
Title: '.equals()'
Description: 'Returns true if two strings are equal in value and false otherwise.'
Subjects:
- 'Computer Science'
Tags:
- 'Booleans'
- 'Strings'
- 'Methods'
CatalogContent:
- 'learn-java'
- 'paths/computer-science'
---

The **`.equals()`** method returns `true` if two strings are equal in value. Otherwise, `false` is returned.

## Syntax

```pseudo
string.equals(object);
```

The `object` can either be a string literal or a representation of a `String` value. This will return `true` if the `string` has the same character sequence as `object`.

## Example

The following example showcases the `.equals()` method:

```java
import java.io.*;

public class MyClass {
public static void main(String[] args) {
// With string literals
System.out.println("4".equals("four"));

// With string objects
String myFavoriteLanguage = "Java";
String codeNinjasFavoriteLangauge = "Java";
System.out.println(myFavoriteLanguage.equals(codeNinjasFavoriteLangauge));
}
}
```

This will print the following output:

```shell
false
true
```
38 changes: 38 additions & 0 deletions content/java/concepts/strings/terms/length/length.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
Title: '.length()'
Description: 'Returns the number of characters contained in a string.'
Subjects:
- 'Computer Science'
Tags:
- 'Characters'
- 'Strings'
- 'Methods'
CatalogContent:
- 'learn-java'
- 'paths/computer-science'
---

The **`.length()`** method returns the number of characters contained in a string.

## Syntax

```pseudo
string.length()
```

No parameters are required for the `.length()` method.

## Example

The `.length()` method is showcased in the following example:

```java
import java.io.*;

class Example {
public static void main(String[] args) {
String greetings = "Hello, Code Ninja!";
System.out.println(greetings.length());
}
}
```
14 changes: 12 additions & 2 deletions content/r/r.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ CatalogContent:

R is a popular open-source interpreted programming language used for statistical computing and graphics. It was created by Ross Ihaka and Robert Gentleman and version 1.0 was released in February 2000.

R supports both procedural and object-oriented programming. Additionally, custom functions and extensions provide expanded functionality.
R supports both procedural and object-oriented programming. Additionally, custom functions and extensions provide expanded functionality. A variety of packages for R are available through the R community. They are widely used by statisticians and data scientists for tasks such as statistics, data analysis, and data visualization.

A variety of packages for R are available through the R community. They are widely used by statisticians and data scientists for tasks such as statistics, data analysis, and data visualization.
One of the most prominent IDEs for R programming is RStudio, which can be downloaded [here](https://www.rstudio.com/products/rstudio/download/).

## Installation

The R programming langauge can be installed via [the Comprehensive R Archive Network (CRAN)](https://cran.r-project.org/). There are separate sets of download instructions for the following operating systems:

- [Windows (Microsoft)](https://cran.r-project.org/bin/windows/)

- [macOS (Apple)](https://cran.r-project.org/bin/macosx/)

- [Linux](https://cran.r-project.org/bin/linux/) (there are separate processes for [Debian](https://cran.r-project.org/bin/linux/debian), [Fedora/Redhat](https://cran.r-project.org/bin/linux/fedora), and [Ubuntu](https://cran.r-project.org/bin/linux/ubuntu))