|
From: | Matt Welland |
Subject: | Re: [Chicken-users] Windows deployment - Numbers egg |
Date: | Sat, 3 Oct 2015 22:31:01 -0700 |
=====================Makefile example===============
PROXY = CHICKEN_INSTALL=chicken-install $(PROXY) -deploy -p farmsim farmsim/farmsim : farmsim.scm boxes.scm common.scm ezxcolors.scm simevents.scm farmsim/coops.so farmsim/format.so farmsim/ezxdisp.so farmsim/ezxgui.so farmsim/qtree.so farmsim/vcd.so farmsim/geolib.so farmsim/pdf.so farmsim/regex.so csc -deploy farmsim.scm farmsim/coops.so : $(CHICKEN_INSTALL) coops farmsim/ezxdisp.so : $(CHICKEN_INSTALL) ezxdisp farmsim/regex.so : $(CHICKEN_INSTALL) regex farmsim/pdf.so : $(CHICKEN_INSTALL) pdf farmsim/format.so : $(CHICKEN_INSTALL) format farmsim/regex.so : $(CHICKEN_INSTALL) regex farmsim/qtree.so : # $(MATTSUTILS)/qtree/qtree.scm $(CHICKEN_INSTALL) qtree -l $(MATTSUTILS) -transport local farmsim/vcd.so : # $(MATTSUTILS)/vcd/vcd.scm $(CHICKEN_INSTALL) vcd -l $(MATTSUTILS) -transport local farmsim/ezxgui.so : # $(MATTSUTILS)/ezxgui/ezxgui.scm $(CHICKEN_INSTALL) ezxgui -l $(MATTSUTILS) -transport local farmsim/geolib.so : # $(MATTSUTILS)/geolib/geolib.scm $(CHICKEN_INSTALL) geolib -l $(MATTSUTILS) -transport local
I have been learning Chicken by incrementally building a program that returns a number of digits of Pi based on an already-existing algorithm that implements the Chudnovsky method. I have a command line version working, thanks to all of the help here, that writes the file as well as displays the output in the command line.If I just: csc Pi-Ch.scm I get a 77kB exe that runs fine on my machine. In order to share it with my son, I need to statically compile it with all of its dependencies, like so:csc -deploy -static Pi-Ch.scmI returns an error:Error: (require) cannot load extension: numbersI found the numbers.so file, but Windows needs a dll file. I plan on downloading the numbers egg source, and seeing if there's any reason I could not compile the numbers.so file to numbers.dll. Any leads or tips?
Call history:
Pi-Ch.scm:16: ##sys#require <--Next step will be to create an IUP GUI for the program to complete the exercise.Thanks!RobPS: Here's the code to date:;;; Program to use the chudnovsky formula to compute pi.
;;; Written by Bakul Shah.
;;; Changed by Bradley Lucier to use standard arithmetic operations
;;; available in Gambit Scheme and to replace (floor (/ ...)) by
;;; (quotient ...)
;; Don't try running this benchmark with Gauche, it'll consume all
;; your computer's memory!
;;;; I removed the conditional statements to make it run across different
;;;; scheme implementations.
;;;; I added the use numbers and extras at the top, and the last 8 lines
;;;; to prompt user and to display the results and write to a file.
;;;; TODO: Deploy to Windows 32-bit, and create an IUP-based GUI for it.
;;;; RPH - 4/10/2015
(use numbers extras)
(define integer-sqrt exact-integer-sqrt)
(define ch-A 13591409)
(define ch-B 545140134)
(define ch-C 640320)
(define ch-C^3 (expt 640320 3))
(define ch-D 12)
(define (ch-split a b)
(if (= 1 (- b a))
(let ((g (* (- (* 6 b) 5) (- (* 2 b) 1) (- (* 6 b) 1))))
(list g
(quotient (* ch-C^3 (expt b 3)) 24)
(* (expt -1 b) g (+ (* b ch-B) ch-A))))
(let* ((mid (quotient (+ a b) 2))
(gpq1 (ch-split a mid)) ;<<<<====
(gpq2 (ch-split mid b)) ;<<<<====
(g1 (car gpq1)) (p1 (cadr gpq1)) (q1 (caddr gpq1))
(g2 (car gpq2)) (p2 (cadr gpq2)) (q2 (caddr gpq2)))
(list (* g1 g2)
(* p1 p2)
(+ (* q1 p2) (* q2 g1))))))
(define (pich digits)
(let* ((num-terms (inexact->exact (floor (+ 2 (/ digits 14.181647462)))))
(sqrt-C (integer-sqrt (* ch-C (expt 100 digits)))))
(let* ((gpq (ch-split 0 num-terms))
(gs (car gpq)) (p (cadr gpq)) (q (caddr gpq)))
(quotient (* p ch-C sqrt-C) (* ch-D (+ q (* p ch-A)))))))
(print "How many digits of Pi to compute?")
(define digits (read))
(print "Here you go:")
(print (pich digits))
(define file-name "pidigits.txt")
(with-output-to-file file-name
(lambda ()
(format #t "~A~%" (pich digits))))
_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users
[Prev in Thread] | Current Thread | [Next in Thread] |