Skip to content

Instantly share code, notes, and snippets.

@gwerbin
Last active November 1, 2021 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwerbin/a7fd2be768999618bfa54a833afa8f64 to your computer and use it in GitHub Desktop.
Save gwerbin/a7fd2be768999618bfa54a833afa8f64 to your computer and use it in GitHub Desktop.
Proposal for `%foreignImport`
(library (double-stuff utils)
(export idris-fl=)
(import (chezscheme))
(define (idris-fl=-2 x0 x1)
(if (fl= x0 x1) 1 0))
(define (idris-fl=-3 x0 x1 x2)
(if (fl= x0 x1 x2) 1 0))
(define (idris-fl=-4 x0 x1 x2 xe)
(if (fl= x0 x1 x2 x3) 1 0))
(define (idris-fl=-apply x0 . xs)
(let ((args (cons x0 xs)))
(if (apply fl= args) 1 0))))
from functools import reduce
from operator import eq
def idris_fleq2(x, y):
return x == y
def idris_fleq3(x, y, z):
return x == y == z
def idris_fleq4(w, x, y, z):
return w == x == y == z
def idris_fleq_many(*xs):
return reduce(eq, xs)
module DoubleStuff
%foreignImport "scheme,chez:(double-stuff utils)"
"python:double_stuff"
-- "python:double_stuff,*"
namespace Exact
%foreign "scheme,chez:idris-fl=-2"
"python:double_stuff.idris_fleq2"
-- "python:idris_fleq2"
doubleEqual : Double -> Double -> Bool
%foreign "scheme,chez:idris-fl=-3"
"python:double_stuff.idris_fleq3"
-- "python:idris_fleq3"
doubleEqual3 : Double -> Double -> Double -> Bool
%foreign "scheme,chez:idris-fl=-4"
"python:double_stuff.idris_fleq4"
-- "python:idris_fleq4"
doubleEqual4 : Double -> Double -> Double -> Double -> Bool
namespace Many
%foreign "scheme,chez:idris-fl=-apply"
"python:double_stuff.idris_fleq_many"
-- "python:idris_fleq_many"
doubleEqual : List Double -> Bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment