This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const Real = f32; | |
const Rational = struct { numerator: i32, denominator: i32 }; | |
const Number = union(enum) { real: Real, rational: Rational }; | |
const PrintVisitor = struct { | |
pub fn visit(n: Number) void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"basics": { | |
"name": "José Ramón Álvarez Rojo", | |
"label": "Software Engineer", | |
"email": "jsrmalvarez@ninjatic.engineer", | |
"url": "https://ninjatic.engineer", | |
"summary": "Software Engineer with over 15 years of expertise in C++, as well as React, embedded device development, Rust, Java and Python. Proficient in backend, frontend, and embedded systems projects, contributing in the process automation industry.", | |
"location": { | |
"region": "Madrid", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Copy, Clone)] | |
struct Rational { | |
numerator:i32, | |
denominator:i32, | |
} | |
#[derive(Copy, Clone)] | |
enum Number{ | |
Real(f32), | |
Rational(Rational), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <variant> | |
#include <cstdlib> | |
using Real = double; | |
struct Rational { | |
int numerator; | |
int denominator; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STATIC_ASSERT(condition) // Error if condition doesn't hold |