Welcome to the CHICKEN Scheme pasting service

gettimeofday example added by wasamasa on Mon Apr 27 15:02:11 2020

(import scheme)
(import (chicken base))
(import (chicken foreign))

#>
#include <stddef.h>
#include <sys/time.h>
<#

(define (current-timestamp)
  (let-location ((sec long 0)
                 (usec long 0))
    ((foreign-lambda* void (((c-pointer long) sec) ((c-pointer long) usec))
       "struct timeval tp; gettimeofday(&tp, NULL);"
       "*sec = tp.tv_sec; *usec = tp.tv_usec;")
     (location sec)
     (location usec))
    (cons sec usec)))

(let* ((timestamp (current-timestamp))
       (sec (car timestamp))
       (usec (cdr timestamp)))
  (print (exact->inexact (+ sec (/ usec 1000000)))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the one-argument procedure to check if a list is empty?
Visually impaired? Let me spell it for you (wav file) download WAV