Skip to content
Snippets Groups Projects
Commit 92f5ed6c authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Switch to flavored code snippets.

parent 315de703
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
## Iterative Reducers ## Iterative Reducers
``` ```js
function iterativeReduce(monoid, sequence) { function iterativeReduce(monoid, sequence) {
let result = monoid.identity; let result = monoid.identity;
for (const element of sequence) { for (const element of sequence) {
...@@ -71,7 +71,7 @@ function iterativeReduce(monoid, sequence) { ...@@ -71,7 +71,7 @@ function iterativeReduce(monoid, sequence) {
## Recursive Reducers ## Recursive Reducers
``` ```js
function recursiveReduce(monoid, sequence) { function recursiveReduce(monoid, sequence) {
if (sequence.length === 0) { if (sequence.length === 0) {
return monoid.identity; return monoid.identity;
...@@ -122,7 +122,7 @@ function recursiveReduce(monoid, sequence) { ...@@ -122,7 +122,7 @@ function recursiveReduce(monoid, sequence) {
* In Code: * In Code:
``` ```js
async function parallelReduce(monoid, sequence, threadCount) { async function parallelReduce(monoid, sequence, threadCount) {
const jobs = []; const jobs = [];
for (let threadIndex = 0; threadIndex < threadCount; ++threadIndex) { for (let threadIndex = 0; threadIndex < threadCount; ++threadIndex) {
...@@ -241,7 +241,7 @@ Problem: Given a string of parentheses, determine if the parentheses are balance ...@@ -241,7 +241,7 @@ Problem: Given a string of parentheses, determine if the parentheses are balance
## Clues about the Monoid from an Iterative Design ## Clues about the Monoid from an Iterative Design
``` ```js
function isBalanced(parentheses) { function isBalanced(parentheses) {
let nesting = 0; let nesting = 0;
for (const character of parentheses) { for (const character of parentheses) {
...@@ -300,7 +300,7 @@ function isBalanced(parentheses) { ...@@ -300,7 +300,7 @@ function isBalanced(parentheses) {
## New Iterative Solution ## New Iterative Solution
``` ```js
function encode(character) { function encode(character) {
if (character === '(') { if (character === '(') {
return [, ]; return [, ];
...@@ -327,7 +327,7 @@ function iterativeReduce(parentheses) { ...@@ -327,7 +327,7 @@ function iterativeReduce(parentheses) {
## Parallel Solution ## Parallel Solution
``` ```js
async function parallelReduce(parentheses, threadCount) { async function parallelReduce(parentheses, threadCount) {
const jobs = []; const jobs = [];
for (let threadIndex = 0; threadIndex < threadCount; ++threadIndex) { for (let threadIndex = 0; threadIndex < threadCount; ++threadIndex) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment