Author Topic: TinyScheme  (Read 63627 times)

0 Members and 2 Guests are viewing this topic.

RobbeK

  • Guest
Re: TinyScheme
« Reply #15 on: August 25, 2014, 12:34:43 AM »
John,

in the code change T  into #t and you're there -- I'll make an iterative version, so you can compare the speed


best Rob

JRS

  • Guest
Re: TinyScheme
« Reply #16 on: August 25, 2014, 12:37:48 AM »
Sweet! Tried it from SB (ext. module) but it only shot blanks where the Mandelbrot should have displayed. Other than that, it worked.

Code: [Select]
(define grid '())
(define mapped-grid '())

(define modulus
  (lambda (n d)
     (let (( r (floor (/ n d))))
      (- n (* r d)))))

(define cadr
    (lambda (L)
      (car (cdr L))))

(define sqrt
     (lambda (x)
       (exp (/ (log x) 2))))

(define sq (lambda(x) (* x x)))

(define 1- (lambda (x) (- x 1)))
(define 1+ (lambda (x) (+ x 1)))

(define level
 (lambda (i x y rc ic it orb)
  (if (or (= i it) (> orb 4)) i
    (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y))))))

(define mlevel
   (lambda (L)
     (level 0 (cadr L) (car L) (cadr L) (car L) 11 0)))

(define fill-grid
   (lambda (nrx xo dx nry yo dy matrix dup)
       (if (and (= 0 nrx) (= 0 nry)) matrix
         (if (= 0 nry) (fill-grid (1- nrx) xo dx dup yo dy matrix dup)
           (fill-grid nrx xo dx (1- nry) yo dy
            (cons (list (+ xo (* nrx dx)) (+ yo (* nry dy))) matrix) dup)))))

(define square-grid
   (lambda (nr x y dz)
     (fill-grid (1- nr) (+ x dz) dz nr y dz '() nr)))

(define map-grid
   (lambda (L)
     (map mlevel L)))

(define display*
  (lambda (x)
    (if (> x 9)
      (display x)
      (begin (display x) (display '" ")) )))

(define print-grid
   (lambda (i it L)
     (if (null? L) #t
       (if (= i it) (begin (display* (car L)) (newline) (print-grid 0 it L))
         (begin (display* (car L)) (print-grid (1+ i) it (cdr L)))))))

(define main
  (lambda ()
    (set! grid (square-grid 30 -1.7 -2.3 0.1))
    (set! mapped-grid (map-grid grid))
    (print-grid 0 30 mapped-grid)
))
(main)
(quit)


Code: [Select]
jrs@laptop:~/tinyscheme/tinyscheme-1.41$ time ./scheme mbrot.scm
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1
1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1
1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 1
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2 2 1
1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2 2 1
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3 2 1
1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3 3 1
1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3 3 1
1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3 3 1
1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3 3 1
1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4 3 1
1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4 3 1
1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4 3 1
1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4 3 1
1 1 1111111111111111111111111111111111111111111111117 5 4 3 1
1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4 3 1
1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4 3 1
1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4 3 1
1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4 3 1
1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3 3 1
1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3 3 1
1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3 3 1
1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3 3 1
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3 2 1
1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2 2 1
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2 2 1
1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2 2 1
1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2
real 0m2.377s
user 0m2.368s
sys 0m0.004s
jrs@laptop:~/tinyscheme/tinyscheme-1.41$
« Last Edit: August 25, 2014, 12:46:45 AM by John »

RobbeK

  • Guest
Re: TinyScheme
« Reply #17 on: August 25, 2014, 01:01:43 AM »
Hi John,

Finished ...............

The source is at the bottom of the ini-file , this way it starts automatically when hitting the exec.
It's alot more compact with iteration ,   the Mandelbrot calc is recursive however ,   best of both worlds.

best Rob
TinyScheme, looks complete and powerfull

-----------------

(newline)
(newline)
(display "Ascii Mandelbrot TinyScheme") (newline)
(display "---------------------------") (newline)

(define sq
   (lambda (x) (* x x)))

(define (1+ x) (+ x 1))
(define (1- x) (- x 1))

(define level
  (lambda (i x y rc ic it orb)
   (if (or (= i it) (> orb 4)) i
    (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y))))))

(define mlevel
   (lambda (L)
     (level 0 (cadr L) (car L) (cadr L) (car L) 11 0)))

(define (main)
   (let ((cnt 0) (lvl 0) (xo -1.7) (yo -2.3) (dz 0.1) )
     (do ((i 0 (1+ i)))
         ((= i 30))
        (do ((j 0 (1+ j)))
            ((= 30 j))
              (set! lvl (mlevel (list (+ xo (* i dz)) (+ yo (* j dz)) )))
              (if (< lvl 10)
                   (begin (display lvl) (display " "))
                   (display lvl))
              (set! cnt (1+ cnt))
              (when (= 30 cnt)
                 (set! cnt 0)
                 (newline))
))))
   
(main)

--------------------------------------------------



.

JRS

  • Guest
Re: TinyScheme
« Reply #18 on: August 25, 2014, 06:11:34 AM »
Quote
TinyScheme, looks complete and powerful

Let's make that the quote of the day.  8)

mbrot2.scm
Code: [Select]
(newline)
(newline)
(display "Ascii Mandelbrot TinyScheme") (newline)
(display "---------------------------") (newline)

(define sq
   (lambda (x) (* x x)))

(define (1+ x) (+ x 1))
(define (1- x) (- x 1))

(define level
  (lambda (i x y rc ic it orb)
   (if (or (= i it) (> orb 4)) i
    (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y))))))

(define mlevel
   (lambda (L)
     (level 0 (cadr L) (car L) (cadr L) (car L) 11 0)))

(define (main)
   (let ((cnt 0) (lvl 0) (xo -1.7) (yo -2.3) (dz 0.1) )
     (do ((i 0 (1+ i)))
         ((= i 30))
        (do ((j 0 (1+ j)))
            ((= 30 j))
              (set! lvl (mlevel (list (+ xo (* i dz)) (+ yo (* j dz)) )))
              (if (< lvl 10)
                   (begin (display lvl) (display " "))
                   (display lvl))
              (set! cnt (1+ cnt))
              (when (= 30 cnt)
                 (set! cnt 0)
                 (newline))
))))

(main)
(quit)

Output

Code: [Select]
jrs@laptop:~/tinyscheme/tinyscheme-1.41$ time ./scheme mbrot2.scm


Ascii Mandelbrot TinyScheme
---------------------------
1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2
1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2
1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3
1 1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3
1 1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3
1 1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3
1 1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4
1 1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4
1 1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4
1 1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4
1 1 1 1111111111111111111111111111111111111111111111117 5 4
1 1 1 1 4 4 6 6 7 1111111111111111111111111111111111118 5 4
1 1 1 1 4 4 4 5 5 6 8 11111111111111111111111111111111115 4
1 1 1 1 3 4 4 4 5 5 7 111111119 1111111111111111111111116 4
1 1 1 1 3 3 3 3 4 5 7 7 7 7 7 7 11111111111111111111119 5 4
1 1 1 1 2 3 3 3 3 3 4 5 5 5 5 6 8 111111111111111111117 5 3
1 1 1 1 2 3 3 3 3 3 3 3 4 4 5 5 6 11111111111111111111114 3
1 1 1 1 1 2 3 3 3 3 3 3 3 4 4 4 5 7 8 8 101111119 6 6 5 4 3
1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 8 1111116 5 5 4 3 3
1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 4 4 4 4 5 6 9 118 5 4 4 3 3 3
1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 5 7 9 114 4 3 3 2 2
1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 4 4 4 115 4 4 3 3 2 2 2
1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 2 2 2 2 2

real 0m0.660s
user 0m0.608s
sys 0m0.000s
jrs@laptop:~/tinyscheme/tinyscheme-1.41$

@Rob - How did you make the .exe version you sent in the zip?

RobbeK

  • Guest
Re: TinyScheme
« Reply #19 on: August 25, 2014, 10:19:08 AM »
Hi John,

When something as GIMP uses it for its scripts , quatlity should be certified ...
The exe is a Lispish trick , it's the whole system renamed and the source of the program added in the init file  8)

However :  **********warning***************

The 1.41 is compiled with USE_MATH 0 ,  things like sin , cos , sqrt , floor ,ceiling etc etc will not work   - can you recompile with USE_MATH 1 ?  (i don't have a C compiler)

In the mean time switched  to 1.39  -- another benchmark test :  finding the primes below 5000  -- it's fast !!

----------------------------------------------------------------------------------

(newline)
(display "start")
(newline)


(define (seq x)
   (let ((M '()))
     (do ((i 0 (+ i 1)))
         ((> i x))
         (set! M (cons i M))) M ))

(define numbers (reverse (seq 4999)))

 

(define (sieve L)
   (let ( ( len (- (length L) 2)) (vec (list->vector L)) )
     (do ((i 2 (+ i 1)))
         ((> i (floor (/ len 2))))
         
         (when (> (vector-ref vec i) 0)
            (do ((j 2 (+ j 1)))
                ((> (* i j) len))
               
                (vector-set! vec (* i j) 0)))) vec ))

(define (print-vec V)
   (let ((len (vector-length V)) (cnt 0) )
     (do (( i 2 (+ 1 i)))
         (( = i (- len 1)))
         (let (( item (vector-ref V i)))
           (when (not (= item 0))
              (set! cnt (+ 1 cnt))
              (display item)
              (display " ")))) cnt ))

(define (main)
  (let ((cnt 0))
   (newline)
   (display "calculating prime-numbers < 5000")  (newline)
   (display "--------------------------------")  (newline)
   (set! cnt (print-vec (sieve numbers)))
   (newline)
   (display "that's it")
   (newline)
   (display cnt) (display "  prime numbers found") ))


(main)   

---------------------------------------  attached in an exec.

It has vectors !!!  -- this is very ! important , vectors are "typed" and are indexed , lists not and have to be assigned in a recursive way -- this is much faster  ,  it's always possible to convert with (list->vector ) [if of a same type, of course , but calculations will speed up a lot ]  and (vector->list )   (unlike CL only one dimension is possible , but for 2D you can make a set of 2 vectors p.e.   for 3D - 3 etc...)

best Rob,  this looks very good
(oops yes for primes < 10000 , you will have to allocate more memory -- not sure it can be done without recompiling (but I do not know)





.
« Last Edit: August 25, 2014, 10:29:59 AM by RobbeK »

JRS

  • Guest
Re: TinyScheme
« Reply #20 on: August 25, 2014, 10:30:27 AM »
Thanks for the feedback and positive news!

I will recompile the Windows 32 bit version enabling MATH and see if I can expand the memory limits. Is there anything else you want enabled?

Code: [Select]
#if USE_NO_FEATURES
define USE_MATH 1
# define USE_CHAR_CLASSIFIERS 0
# define USE_ASCII_NAMES 0
# define USE_STRING_PORTS 0
# define USE_ERROR_HOOK 0
# define USE_TRACING 0
# define USE_COLON_HOOK 0
# define USE_DL 0
# define USE_PLIST 0
#endif


« Last Edit: August 25, 2014, 10:46:30 AM by John »

RobbeK

  • Guest
Re: TinyScheme
« Reply #21 on: August 25, 2014, 11:42:48 AM »
Hi John,

Maybe USE_TRACING 1 too ??     don't know it makes any sense in an embedded app.  , in the script (tracing) turns it on , and (tracing 0) off

From USE_DL, the documentation explains :
 USE_DL
     Enables dynamically loaded routines. If you define this symbol, you
     should also include dynload.c in your compile.

Once again - if embedded ??    -- but do the things following your needs , (only for playing with TinyScheme  the Math's are very welcome here , and certainly needed (for you) as an embedded app )

best Rob

RobbeK

  • Guest
Re: TinyScheme
« Reply #22 on: August 25, 2014, 12:05:58 PM »
Perfect John  :)
addendum :
I think it's possible to allocate more memory-segments from within the script -- (without any need to recompile )

JRS

  • Guest
Re: TinyScheme
« Reply #23 on: August 25, 2014, 12:20:13 PM »
Quote
I think it's possible to allocate more memory-segments from within the script -- (without any need to recompile )

That would be slick!  I didn't see anything obvious in the source to control memory use in the definition section.

RobbeK

  • Guest
Re: TinyScheme
« Reply #24 on: August 25, 2014, 12:34:32 PM »
John,

 (new-segment <num>)
     Allocates more memory segments.

 :)

it has streams too , it seems (that little devil  8)     --  I'll study the documentation tomorrow , I had only a quick reading this morning from the init - file    --  I'm very surprised it's even capable to define your own syntax macro's just like its big brothers,

best Rob

JRS

  • Guest
Re: TinyScheme
« Reply #25 on: August 25, 2014, 01:52:12 PM »
A lot of amazing in that little package and best of all faster than a speeding bullet. I'm happy!

jrs@laptop:~/tinyscheme/Rob$ time tinyscm primes.scm

start

calculating prime-numbers < 5000
--------------------------------
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083 3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221 3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331 3343 3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467 3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581 3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 3691 3697 3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823 3833 3847 3851 3853 3863 3877 3881 3889 3907 3911 3917 3919 3923 3929 3931 3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073 4079 4091 4093 4099 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211 4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 4297 4327 4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457 4463 4481 4483 4493 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591 4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721 4723 4729 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861 4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973 4987 4993
that's it
668  prime numbers found
real   0m4.064s
user   0m4.052s
sys   0m0.004s
jrs@laptop:~/tinyscheme/Rob$

Here is a C primes example.

Code: [Select]
#include <stdio.h>

int main()
{
  int n1, n2=5000, i, j, flag;
  for(i=n1+1; i<n2; ++i)
  {
      flag=0;
      for(j=2; j<=i/2; ++j)
      {
        if(i%j==0)
        {
          flag=1;
          break;
        }
      }
      if(flag==0)
        printf("%d ",i);
  }
  return 0;

jrs@laptop:~/tinyscheme/Rob$ time ./primes
1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 947 953 967 971 977 983 991 997 1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097 1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193 1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297 1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399 1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499 1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597 1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699 1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789 1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889 1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999 2003 2011 2017 2027 2029 2039 2053 2063 2069 2081 2083 2087 2089 2099 2111 2113 2129 2131 2137 2141 2143 2153 2161 2179 2203 2207 2213 2221 2237 2239 2243 2251 2267 2269 2273 2281 2287 2293 2297 2309 2311 2333 2339 2341 2347 2351 2357 2371 2377 2381 2383 2389 2393 2399 2411 2417 2423 2437 2441 2447 2459 2467 2473 2477 2503 2521 2531 2539 2543 2549 2551 2557 2579 2591 2593 2609 2617 2621 2633 2647 2657 2659 2663 2671 2677 2683 2687 2689 2693 2699 2707 2711 2713 2719 2729 2731 2741 2749 2753 2767 2777 2789 2791 2797 2801 2803 2819 2833 2837 2843 2851 2857 2861 2879 2887 2897 2903 2909 2917 2927 2939 2953 2957 2963 2969 2971 2999 3001 3011 3019 3023 3037 3041 3049 3061 3067 3079 3083 3089 3109 3119 3121 3137 3163 3167 3169 3181 3187 3191 3203 3209 3217 3221 3229 3251 3253 3257 3259 3271 3299 3301 3307 3313 3319 3323 3329 3331 3343 3347 3359 3361 3371 3373 3389 3391 3407 3413 3433 3449 3457 3461 3463 3467 3469 3491 3499 3511 3517 3527 3529 3533 3539 3541 3547 3557 3559 3571 3581 3583 3593 3607 3613 3617 3623 3631 3637 3643 3659 3671 3673 3677 3691 3697 3701 3709 3719 3727 3733 3739 3761 3767 3769 3779 3793 3797 3803 3821 3823 3833 3847 3851 3853 3863 3877 3881 3889 3907 3911 3917 3919 3923 3929 3931 3943 3947 3967 3989 4001 4003 4007 4013 4019 4021 4027 4049 4051 4057 4073 4079 4091 4093 4099 4111 4127 4129 4133 4139 4153 4157 4159 4177 4201 4211 4217 4219 4229 4231 4241 4243 4253 4259 4261 4271 4273 4283 4289 4297 4327 4337 4339 4349 4357 4363 4373 4391 4397 4409 4421 4423 4441 4447 4451 4457 4463 4481 4483 4493 4507 4513 4517 4519 4523 4547 4549 4561 4567 4583 4591 4597 4603 4621 4637 4639 4643 4649 4651 4657 4663 4673 4679 4691 4703 4721 4723 4729 4733 4751 4759 4783 4787 4789 4793 4799 4801 4813 4817 4831 4861 4871 4877 4889 4903 4909 4919 4931 4933 4937 4943 4951 4957 4967 4969 4973 4987 4993 4999
real   0m0.011s
user   0m0.004s
sys   0m0.004s
jrs@laptop:~/tinyscheme/Rob$
« Last Edit: August 25, 2014, 02:47:39 PM by John »

JRS

  • Guest
TinyScheme - 1.41 Download
« Reply #26 on: August 25, 2014, 06:34:31 PM »
Rob,

I have correctly built the TinyScheme 1.41 release on Windows XP using the latest MinGW-TDM GCC. The attached zip also includes the libtinyscheme.dll, libtinyscheme.a and the makefile I changed for MinGW use. I also included the Ubuntu 64 bit version. (console mode TinySchmene executable, init.scm and Manual.txt only - get the distribution from SourceForge to rebuild)

Please Test!




.
« Last Edit: August 25, 2014, 09:36:08 PM by John »

JRS

  • Guest
Re: TinyScheme
« Reply #27 on: August 25, 2014, 08:31:28 PM »
Rob,

I download the RE (regular expression) extension for TinyScheme. I'm going to try and compile the re.so under Linux and if it seems to work then I'll create a re.dll for you to test. Until then here is re.scm option. The code is over 12 years old. If you think it would be worth building a C RE extension module then I will have to dig up current source. The readme said it was experimental (at the time) so I have no idea of its current state. Nice to have the .scm version of it though.


Quote from: README.1st
             TinyScheme RE (Regular Expressions) extension
             ---------------------------------------------
Version 1.2, August 2002

The bulk of this directory is the regular expression library written
by Henry Spencer (see file README and COPYRIGHT).

Two files were added to produce the TinyScheme regular expression
library, re.so: re.c and re.makefile. The included re.makefile was contributed
initially by Stephen Gildea and should be adaptable to all Unix systems.

The makefile produces a DLL named re.so. For now, it contains just
a single foreign function (re-match <pattern> <string>). It returns
true (string matches pattern) or false. If it is called with an
extra parameter, which should be a vector, overwrites as many elements
of the vector as needed with the strings that matched the corresponding
parenthesized subexpressions inside <pattern>.

It is not fully tested, so use with caution.

Load the extension from inside TinyScheme using
(load-extension "re/re")
assuming that re.so is in the directory "re".

Load "re.scm" if you wish to use v.1.1 behavior.


Code: [Select]
;; return the substring of STRING matched in MATCH-VECTOR,
;; the Nth subexpression match (default 0).
(define (re-match-nth string match-vector . n)
  (let ((n (if (pair? n) (car n) 0)))
    (substring string (car (vector-ref match-vector n))
                    (cdr (vector-ref match-vector n)))))

(define (re-before-nth string match-vector . n)
  (let ((n (if (pair? n) (car n) 0)))
    (substring string 0 (car (vector-ref match-vector n)))))

(define (re-after-nth string match-vector . n)
  (let ((n (if (pair? n) (car n) 0)))
    (substring string (cdr (vector-ref match-vector n))
             (string-length string))))

« Last Edit: August 25, 2014, 08:39:30 PM by John »

JRS

  • Guest
TinyScheme - DLLC
« Reply #28 on: August 25, 2014, 09:15:58 PM »
Charles,

I would like to try TinyScheme with SB and DLLC. Based on the TS docs, I can run multiple TS objects in a single process without issue. This looks like a perfect (non-IUP) multi-threaded use of DLLC. Can you generate a DLLC definition for TinyScheme? The API is reasonably small.

The libtinyscheme.dll was included in the previous TinyScheme 1.41 Windows 32 attachment.




Mike Lobanovsky

  • Guest
Re: TinyScheme - 1.41 Download
« Reply #29 on: August 25, 2014, 09:48:19 PM »
Please Test!

Misses (numerator), (denominator), and (rationalize) that must be part of core language as per the r5rs and r6rs standards of the Scheme language.


Regrets, oh.... excuse me... Regards,