Last active
November 1, 2021 14:29
-
-
Save gwerbin/a7fd2be768999618bfa54a833afa8f64 to your computer and use it in GitHub Desktop.
Proposal for `%foreignImport`
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
(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)))) |
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
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) |
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
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