r/GhanaSoftwareEngineer • • Jul 28 '26

The Comprehensive Racket & Functional Programming Cheat Sheet

5 Upvotes

Phase 1: Syntax & Core Arithmetic

Racket uses prefix notation enclosed in execution parentheses (operator arg1 arg2). The open parenthesis ( acts as an execution trigger. Evaluation runs from the innermost to the outermost parentheses.

Core Examples

;; Basic Arithmetic
(+ 10 5 2) ;; Returns 17
(* 10 5 2) ;; Returns 100

;; Nested Expressions (No PEMDAS needed)
(_ (+ 4 6) (- 12 7)) ;; Evaluates 10 _ 5 -> Returns 50

Parentheses Golden Rule

Only use a parenthesis when invoking a command, operator, or function.

  • (+ 5 (10)) CRASHES (tries to run the number 10 as a function).

  • ((+ 5 5)) CRASHES (evaluates to 10, then tries to run the number 10).


Phase 2: Core Data Structures & Variables

Global bindings are created using define. Values are immutable and cannot be changed over time.

The Four Atomic Data Types

  1. Numbers: Integers (45), decimals (3.14), or fractions (1/3).

  2. Strings: Text wrapped in double quotes ("Hello").

  3. Booleans: True (#t) and False (#f).

  4. Symbols: Lightweight, immutable identifier tokens prefixed with a single quote ('success).

Core Examples

(define radius 5)
(define pi 3.14)
(define status 'success)

Phase 3: Conditionals & Logic

Conditional operations are expressions that evaluate down to a single return value.

Core Operators & Flow Control

  • and / or / not: Standard logical short-circuiting prefix operators.

  • if: Takes exactly three arguments: (if condition true-branch false-branch). No else keyword.

  • cond: Evaluates multiple branches sequentially. Uses/can use [...] for human readability.

Core Examples

(and (> 15 10) (< 15 20)) ;; Returns #t

(if (> temperature 30) 'hot 'cold)

(cond
[(>= score 90) 'A]
[(>= score 80) 'B]
[else 'F])

Phase 4: Functions & Scope

Functions automatically return the value of their body expression without an explicit return keyword.

Named, Anonymous, & Scoped Blocks

  • Named Functions: Defined by grouping the name and parameters in parentheses: (define (name args) body).

  • Anonymous Functions (lambda): Throwaway functions built on the fly: (lambda (args) body).

  • let (Parallel): Creates local variables simultaneously. Variables cannot see each other during setup.

  • let\* (Sequential): Creates local variables one after the other. Later variables can reference earlier ones.

Core Examples

;; Named Function
(define (double n) (\* n 2))

;; Inline Lambda Execution
((lambda (n) (\* n 2)) 10) ;; Returns 20

;; Sequential Local Bindings
(let* ([x 10]
[y (* x 5)])
(+ x y)) ;; Returns 60

Phase 5: Lists & Modern List Operations

Lists are ordered sequential collections. They are processed using either historical Lisp conventions or modern aliases.

Creation & Extraction

  • list: Evaluates arguments into a sequential list.

  • '(): Represents the literal base empty list.

  • cons: Prepends a single element onto the front of an existing list.

  • First Item: Extracted via car (traditional) or first (modern).

  • Remaining List: Extracted via cdr (traditional) or rest (modern).

Core Examples

(define my-list (list 100 #t 'hello)) ;; Creates '(100 #t hello)
(cons 'apples '(bananas cherries)) ;; Returns '(apples bananas cherries)

(car (cdr '(apples bananas cherries))) ;; Returns 'bananas
(first (rest '(apples bananas cherries))) ;; Returns 'bananas

(if (empty? my-list) "Closed" (length my-list)) ;; Returns 3

Phase 6: Iteration & Higher-Order Functions

Instead of using loops that alter data in place, functional programming relies on Higher-Order Functions to process immutable collections.

The Big Four

  • map: Loops over a list, passes each item through a transformation function, and returns a new list.

  • filter: Loops over a list, keeps items that evaluate to #t against a predicate condition, and drops the rest.

  • foldl (Fold-Left): Reduces a list down to a single value by processing elements from left to right (front to back).

  • foldr (Fold-Right): Reduces a list down to a single value by processing elements from right to left (back to front). Preserves list structures when rebuilding with cons.

Core Examples

(map (lambda (x) (* x 2)) '(5 10 15 20)) ;; Returns '(10 20 30 40)
(filter (lambda (n) (= n 5)) '(2 5 7 5 9 1)) ;; Returns '(5 5)

(foldl
  (lambda (n total) (_ n total))
  1
  '(2 3 4)) ;; 4 _ (3 _ (2 _ 1)) -> Returns 24

(foldr
  -
  0
  '(5 3)) ;; 5 - (3 - 0) -> Returns 2

Phase 7: Recursion & Tail Call Optimization (TCO)

Recursion replaces traditional loops. A proper recursive function requires a Base Case (the exit clause) and a Recursive Step (the self-call with a smaller argument).

Memory Optimization Rules

  • Standard Recursion: Traps the recursive call inside another function (like + or append), forcing the call stack memory to expand linearly (O(N) space).

  • Tail Call Optimization (TCO): If the recursive call sits in the tail position (the absolute final expression evaluated), Racket reuses the same memory frame, running in constant (O(1)) space.

  • Accumulator Pattern: Passing a running total down as an argument is the primary strategy used to shift standard recursion into tail position optimization.

Core Examples

;; ❌ Standard Recursion (No TCO - Memory Expands)
(define (sum-list lst)
  (if (empty? lst)
    0
    (+ (first lst) (sum-list (rest lst)))))

;; Tail Recursion (TCO Active - Memory Stays Flat)
(define (sum-list-tco lst)
  (define (helper remaining accumulator)
    (if (empty? remaining)
      accumulator
      (helper
        (rest remaining)
        (+ (first remaining) accumulator))))
    (helper lst 0))

Phase 8: Advanced Ecosystem Engineering

1. Hash Maps & Unique Sets

  • #hash: Stores key-value pairings. Keywords passed to lookup tools like hash-ref must be quoted ('#:key) to prevent compiler namespace collisions. If using standard symbols inside #hash, omit inner quotes.

  • set: Collections guaranteeing element uniqueness. Tested via set-member? and extended via set-add.

(define user #hash((#:name . "Alice")))
(hash-ref user '#:name) ;; Returns "Alice"

(define book #hash((title . "Dune")))
(hash-ref book 'title) ;; Returns "Dune"

(set-member? (set 1 2 2 3) 2) ;; Returns #t

2. State & Mutability (box)

  • box: Creates a reference wrapper around mutable data. Read via unbox and mutated via set-box!. Functions with an exclamation mark ! signal structural mutation.

  • begin: Chains sequential side-effect operations from top to bottom, returning only the evaluation of the final expression.

(define health (box 100))
(define (take-damage!)
(begin
(set-box! health (- (unbox health) 10))
(unbox health)))

3. Type Checking & Casting

  • Predicates (?): Validate runtime types (e.g., string?, number?, symbol?).

  • Casting (->): Converts data formats. string->number safely returns #f if given invalid textual input.

(if (string? "50")
  (* (string->number "50")
  2) 'error) ;; Returns 100

4. Modules & Namespaces

  • provide: Declares which parts of a filesystem file are exported publicly.

  • require: Ingests public features from an external sandbox by loading its relative string filepath.

;; Inside file-a.rkt
(provide double)
(define (double x) (* x 2))

;; Inside main.rkt
(require "file-a.rkt")
(double 10) ;; Returns 20

5. Macros (define-syntax-rule)

  • Macros process raw, unevaluated source code at compile-time to inject new keywords.

  • Racket macros are hygienic, meaning the compiler automatically isolates macro identifiers so they never accidentally overwrite or conflict with user variables.

(define-syntax-rule (swap! box1 box2)
  (let ([temp (unbox box1)])
    (begin
      (set-box! box1 (unbox box2))
      (set-box! box2 temp))))

r/GhanaSoftwareEngineer • • Oct 16 '26

Agoo, wowɔ fie ha

3 Upvotes

Hi All,

I’m a fellow Ghanaian, just joined the sub, wanted to see what tech stack everyone’s working with.

I’m a Python/C/C++ guy, what about you, what tech do you use?


r/GhanaSoftwareEngineer • • Jul 31 '26

Eric Normand's Clojure Resource

Thumbnail ericnormand.me
3 Upvotes

This is a material from Eric that I think you'd find useful in learning clojure

Check out this platform at https://ericnormand.me/


r/GhanaSoftwareEngineer • • Jul 14 '26

Rust from zero by meowy

Thumbnail
youtube.com
3 Upvotes

r/GhanaSoftwareEngineer • • 11d ago

The Complete Beginner’s Guide to Backend Development with Node.js, TypeScript & PostgreSQL

Thumbnail
dev.to
2 Upvotes

Objective

Use Nodejs runtime, Typescript, ExpressJs, Typeorm, PostgreSQL, Beekeeper and Bruno to create an api from scratch. Create a Task and Todo Manager.

Module 1: Foundations & TypeScript

Project Initialization & Tooling

  • Initialize nodejs project environment

    • npm init -y

  • Install and configure Typescript

    • npm install -D typescript @types/node tsx

  • Initialize typescript configuration

    • npx tsc --init

TypeScript Fundamentals for Backend

  • types: string, boolean, number, any

  • variables

const username = "doeman";

let isActive = false;

let age = 25;

const numberOfPoints = [2, 3, 4, 5];

const profile = {
  name: "John Doe",
  isEngineer: true,
};

let profileColor: "red" | "green" | "blue" = "blue";
  • conditions

let color: "red" | "green" | "blue" = "blue";

if (color === "red") {
  console.log("This is red");
} else if (color === "green") {
  console.log("This is green");
} else {
  // this means the default (color
  console.log("This is green");
}

switch (color) {
  case "red": {
    console.log("This is red");
    break;
  }

  case "green": {
    console.log("This is green");
    break;
  }

  case "blue": {
    console.log("This is blue");
    break;
  }

  default: {
    // this means that color is not found
    console.log("It seems we don't know what this color is");
    break;
  }
}
  • operations: +,-, /, *, <, >, <=, >=, === ==, !=

  • interfaces and type aliasing We use interface to define payloads, type request and response bodies. We call these DTO - Data Transfer Object

interface UserInput {
  firstName: string;
  lastName: string;
  age: number;
  address?: {
    addressLineOne: string;
    addressLineTwo?: string;
    countryCode?: string;
  };
}

type Colors = "red" | "green" | "blue";
  • loops and condition

for (const i in [1, 2, 3]) {
  console.log(`do something with element at index i, ${arr[i]}`);
}

for (const i of [1, 2, 3]) {
  console.log(`${i} is an item in arr`);
}

// square and filter out the even numbers
[1, 2, 3].map((i) => i * i).filter((i) => i % 2 === 0);
  • functions and promises (async and await)

function name(params) {}

// call function
name(1, 2);

function addTwoNumbers(a: number, b: number) {
  return a + b;
}

console.log(`The sum of 1 and 2 is ${addTwoNumbers(1, 2)}`);

async function addThreeNumbers(a: number, b: number, c: number) {
  // usually we will put await
  return a + b + c;
}
  • classes

class MyClass {
  properties;
  methods;

  private name: string;

  constructor(name: string) {
    this.name = string;
  }

  constructor(public readonly name: string) {}

  doubleName(): string {
    const fullname = this.name + " " + this.name;
    console.log(fullname);

    return fullname;
  }
}
  • all properties and methods are by default public

  • public: accessible anywhere

  • private: not accessible outside of the class

  • protected: it is private but accessible to sub-classes

  • readonly: prevents the fields from reassignment after initialized

Module 2: HTTP Architecture & Express

The Express Server & Request Lifecycle

Install express for the http server.

npm install express
npm install -D @types/express

In src/index.ts, we bootstrap an express application and add a health-check endpoint

import express, { Request, Response, NextFunction } from "express";

const app = express();

app.use(express.json());

app.get("/health", (req: Request, res: Response, next: NextFunction) => {
  try {
    res.status(200).json({ status: "ok", timestamp: new Date() });
  } catch (error) {
    return next(error);
  }
});

Break down

  • Import express and types needed: import express, { Request, Response, NextFunction } from "express";

  • Create an express app, const app = express();

  • Add a builtin middleware to parse json-payload to JSON: app.use(express.json());

  • Create a GET request, app.get(...)

  • With an endpoint. app.get("/health",...)

  • After this we have a request handler that return a JSON object with properties, status and timestamp

  • req is how data (input) is passed into the controller (request handler)

  • res is how data is passed back (returned) to the client

  • next passes control to the next request handler.

  • When next() is empty, it means everything is fine, move to the middleware (request-handler)

  • When next(error) is not empty, it means there was an error and as such control needs to be passed to the error handling middleware

Update the tsconfig

{
  "compilerOptions": {
    "lib": ["ES2016"],
    "module": "commonjs",
    "target": "es2016",
    "rootDir": "./src",
    "outDir": "./dist",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "strictPropertyInitialization": false,
    "typeRoots": ["./node_modules/@types"],
    "types": ["node"]
  }
}

Update the package.json

{
  ...,
"scripts": {
    "build": "npx tsc",
    "clean": "rm -rf dist",
    "start": "npm run build && node ./dist/index.js"
  },
}

We can now run the command npm run start

Add and listen on a port

Lets add a static port and run this app on port 3000.

app.listen(3000, () => {
  console.log("app is running on port 3000");
});

Request and Response

Say we have req: Request, we can get the user input passed via

  • body as req.body. If there is a specific field we are interested in, we can access it directly as req.body.field

  • headers as req.headers

  • query strings as req.query

  • params as req.params

When returning a response, we can update the status code and return a JSON object by res.status(STATUS_CODE).json({ ...})

Controllers

A controller is a request handler. Requests and responses are handled in the controller. From above, this is a controller.

(req: Request, res: Response, next: NextFunction) => {
  try {
    res.status(200).json({ status: "ok", timestamp: new Date() });
  } catch (error) {
    return next(error);
  }
};

A controller is a function (usually async). In this case we have to create a function for this controller.

Directly we can do:

const healthController = (req: Request, res: Response, next: NextFunction) => {
  try {
    res.status(200).json({ status: "ok", timestamp: new Date() });
  } catch (error) {
    return next(error);
  }
};

I prefer creating or using the function keyword stylistically.

function healthController(req: Request, res: Response, next: NextFunction) {
  try {
    res.status(200).json({ status: "ok", timestamp: new Date() });
  } catch (error) {
    return next(error);
  }
}

The difference between the two functions looks like

const funcName = (params) => {
  // actions
};

and

function funcName(params) {
  // actions
}

Now the health route will look like

function healthController(req: Request, res: Response, next: NextFunction) {
  try {
    res.status(200).json({ status: "ok", timestamp: new Date() });
  } catch (error) {
    return next(error);
  }
}

app.get("/health", healthController);

NB: usually controllers are async

Route Grouping

Another way to create a route is to use the Router function from express. This way we can have a router for each feature of our app and then mount it in the main app (index.ts).

// feature-name/index.ts
// or feature-name/router.ts
import { Router } from "express";

const router = Router();

// here you can add middlewares and routes and mount controllers

export default router;

I usually prefer the /index.ts approach.

We can now import this grouped router in the main app.

// other imports
import tasksRouter from "./tasks";

then we mount the new router under the app.get("/health", healthController);

app.use("/tasks", tasksRouter);

The rest of the module can be found at https://dev.to/otumianempire/the-complete-beginners-guide-to-backend-development-with-nodejs-typescript-postgresql-5a37


r/GhanaSoftwareEngineer • • Oct 14 '26

Yomou v1.1.6 — Kotatsu backup support, fixed source sorting, and a detail screen redesign

2 Upvotes

Hey everyone! Yomou is a free, open-source Android/iOS (sideloadable) manga reader built with native source integration rather than manual extension setups. We've dropped two releases recently (v1.1.5 & v1.1.6)—here is what’s new:

Full Kotatsu Backup Compatibility (v1.1.5)

  • Two-way .bk.zip sync: Full import/export support for Kotatsu backups. Your favorites, reading history, and bookmarks transfer across cleanly.

  • Background Notifications: Backup and import tasks run in the background with live progress scanning for missing titles and a system notification when complete.

Source Engine & Detail Screen Overhaul (v1.1.6)

  • Persistent Source Sorting: Organize sources by 5 modes (Name, Popular, Manual, Last Used, Popular & Reliable) with drag-to-reorder support that persists across restarts.

  • True Server-Side Search: Source search now queries the source directly with debounced requests and real pagination instead of just filtering loaded titles on screen.

  • Kotatsu-Redo UI Redesign: Rebuilt manga detail view with draggable trays, unified quick-apply settings pickers, tap-outside sheet dismissal, and polished Material 3 accent themes.

  • Source Fixes & Cleanup: Fixed search pagination for Arenascan, MangaKatana, Asura Scans, and Flame Scans. Removed broken/unreliable sources (ComicK, Komga, Toonily).

Download & Source Code:

GitHub


r/GhanaSoftwareEngineer • • Sep 26 '26

[Dev Update] Working on Yomou – A new Flutter manga reader (Tachiyomi backup import is officially working!)

2 Upvotes

r/GhanaSoftwareEngineer • • Apr 10 '26

C as First language.

Thumbnail reddit.com
2 Upvotes

r/GhanaSoftwareEngineer • • Mar 23 '26

🚫 When do you say no to nodejs?

2 Upvotes

Nodejs is the crowd's favourites. We have see improvements over the years. However, it begs to ask, CEO of start ups, CTOs, product owners and engineers, when do you say nodejs, "enough"?

what are some metrics or situations, you may consider, weighing in on the pros and cons? what platform (stack) do you consider switching to? In the case that you switched, what are the preparations that are made considering team side and budget?


r/GhanaSoftwareEngineer • • Mar 20 '26

👋 Welcome to r/GhanaSoftwareEngineer - Introduce Yourself and Read First!

2 Upvotes

Hey everyone! I'm u/kaishibou, a founding moderator of r/GhanaSoftwareEngineer.

This is our new home for all things related to the craft of programming and the technical discipline of software engineering. We're excited to have you join us!

What to Post

Post anything that you think the community would find interesting, helpful, or inspiring. Feel free to share your thoughts, photos, or questions about system architecture, debugging complex edge cases, code reviews, local engineering challenges, or your personal software development journey.

Community Vibe

We're all about being friendly, constructive, and inclusive. Let's build a space where everyone feels comfortable sharing and connecting.

How to Get Started

  • Introduce yourself in the comments below.

  • Post something today! Even a simple question can spark a great conversation.

  • If you know someone who would love this community, invite them to join.

  • Interested in helping out? We're always looking for new moderators, so feel free to reach out to me to apply.

Thanks for being part of the very first wave. Together, let's make r/GhanaSoftwareEngineer amazing.


r/GhanaSoftwareEngineer • • Mar 20 '26

Hello world: What do you do to recover

2 Upvotes

One thing I have immerse myself into is writing. This is not limited to articles (as in the link below) but poetry - they said, 'you must have a creative side'. It is a way for me to "recover".

https://dev.to/otumianempire/series/26412

The intention behind this sub is mainly for the craftsmanship of softwares and its related endeavours. I have also loved "building in public". I find it an important to process to gain confidence and share your journey with others.

To early members, what do you do to "recover" or reset after a long day?

Let's craft "something" meaningful and avoid buzzwords. Who is up for it?


r/GhanaSoftwareEngineer • • 2d ago

Looking for engineers interested in collaborating on an upcoming SaaS project (Web, Mobile, Backend, DevOps, AI/ML)

Thumbnail
reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • May 06 '26

How Uber matches 10 million+ rides in a day ??

Thumbnail
youtu.be
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 20 '26

Reality check: where do we still write C?

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 18 '26

Entry experience for low level and C jobs

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 15 '26

New to Ubuntu & Cybersecurity – What tools should I install to start learning SOC Analyst skills?

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 15 '26

I am sick and tired of the constant upskilling expectations in Indian IT industry

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 15 '26

How would I write my own compiler from scratch?

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 14 '26

Have .NET 'influencers' became doomsayers?

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 14 '26

Small Projects

Thumbnail reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 11 '26

I built a Cargo-like tool for C/C++

Thumbnail
reddit.com
1 Upvotes

r/GhanaSoftwareEngineer • • Apr 11 '26

Is web development still worth getting into in 2026 (starting at 23 with no experience)?

Thumbnail reddit.com
1 Upvotes