Skip to content

Instantly share code, notes, and snippets.

View certik's full-sized avatar

Ondřej Čertík certik

View GitHub Profile
certik /
Last active February 27, 2024 15:06
Computational Graph
/* The Computer Language Benchmarks Game
contributed by Martin Jambrek
based off the Java #2 program contributed by Mark C. Lewis and modified slightly by Chad Whipkey
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <stdio.h>
int main()
#define REPEAT(count, action) REPEAT_HELPER(count, action)
#define REPEAT_HELPER(count, action) \
#define REPEAT_1(action) action(1)
#define REPEAT_2(action) action(2) REPEAT_1(action)
#define REPEAT_3(action) action(3) REPEAT_2(action)
module semigroup_m
!! A semigroup is a type with a sensible operation for combining two objects
!! of that type to produce another object of the same type.
!! A sensible operation has the associative property (i.e. (a + b) + c == a + (b + c))
!! Given this property, it also makes sense to combine a list of objects of
!! that type into a single object, or to repeatedly combine an object with
!! itself. These operations can be derived in terms of combine.
!! Examples include integer (i.e. +), and character (i.e. //)
implicit none


LFortran - modern interactive LLVM-based Fortran compiler


lfortran [OPTIONS] [files...] [SUBCOMMAND]


certik / a.f90
Created December 1, 2023 15:12
PROGRAM Calibration
INTEGER :: total_sum, first_digit, last_digit, calibration_value
CHARACTER(100), DIMENSION(:), ALLOCATABLE :: calibration_document
INTEGER :: i, len_line, char_value, status
! Initialize total sum
total_sum = 0
certik / a.f90
Created November 11, 2023 00:31
program XX
requirement is_binary_op(T, op)
type, deferred :: T
function op(lhs, rhs) result(res)
type(T), intent(in) :: lhs, rhs
type(T) :: res
end function
end requirement
program expr2
implicit none
integer :: y, z
z = f(y)
print *, z, y
print *, "OK 5"
program mandelbrot
integer, parameter :: Nx = 600, Ny = 450, n_max = 255, dp=kind(0.d0)
real(dp), parameter :: xcenter = -0.5_dp, ycenter = 0.0_dp, &
width = 4, height = 3, dx_di = width/Nx, dy_dj = -height/Ny, &
x_offset = xcenter - (Nx+1)*dx_di/2, y_offset = ycenter - (Ny+1)*dy_dj/2
integer :: image(Nx,Ny), image_color(4,Nx,Ny), palette(3,4), i, j, n, idx
real(dp) :: x, y, x_0, y_0, x_sqr, y_sqr
subroutine show_img(w, h, A) bind(c)
integer, intent(in) :: w, h