Skip to content

Instantly share code, notes, and snippets.

@marcomaggi
marcomaggi / demo.c
Created April 18, 2019 04:29
Toying with fscanf to read/write sampling data to/from a file
/* demo.c --
Compile with:
gcc -Wall -std=c11 -lm -o demo demo.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
;;; case-star.chez --
;;
;;Copyright (C) 2010-2017 Marco Maggi <marco.maggi-ipsu@poste.it>
;;
;;Permission is hereby granted, free of charge, to any person obtaining a copy of
;;this software and associated documentation files (the "Software"), to deal in the
;;Software without restriction, including without limitation the rights to use, copy,
;;modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
;;and to permit persons to whom the Software is furnished to do so, subject to the
;;following conditions:
@marcomaggi
marcomaggi / parallel.sps
Last active August 29, 2015 14:13
A rough demo of using coroutines with Vicare Scheme.
;;;
;;;Part of: Marco's Gists
;;;Contents: A rough demo of using coroutines with Vicare Scheme.
;;;Date: Sat Jan 17, 2015
;;;
;;;Abstract
;;;
;;; This script shows how to run coroutines and how to implement: a PARALLEL
;;; syntax which is syntactic sugar to evaluate coroutines; a MONITOR syntax that
;;; allows only a maximum number of coroutines to enter a critical section of
/* Demo for Libiconv. A simple example to demonstrate the use of
"UCS-4-INTERNAL": convert a string in UTF-8 encoding to an array of
integers representing Unicode code points. To compile the program
with Libiconv on a GNU+Linux system:
$ gcc -o iconv-demo iconv-demo.c -l iconv
*/
#include <stdio.h>
#include <stdlib.h>
@marcomaggi
marcomaggi / expat-gbk-demo.c
Last active December 21, 2015 16:19
Untested example of using the Expat library with GBK encoding, make use of GNU Libiconv.
/* An untested example of using the Expat library with GBK encoding:
read an XML document from stdin and exit. Libiconv is used to
perform the actual conversion from GBK to UTF-8. On a GNU+Linux
system compile it with:
$ gcc -Wall -o expat-gbk-demo expat-gbk-demo.c -liconv -lexpat
A useless XML test file follows:
<?xml version='1.0' encoding='GBK'?>
@marcomaggi
marcomaggi / cholesky-matrix-decomp.sps
Created November 25, 2010 13:18
Cholesky matrix decomposition
;;; Based on the following post:
;;; http://groups.google.com/group/comp.lang.scheme/browse_thread/thread/78170599ca8be8f6#
#!r6rs
(import (rnrs))
(define (Cholesky:decomp P)
(Cholesky:make-square
(let iter ((i 0) (j 0) (L '()))
(if (>= i (length P))