Author Topic: TinyScheme  (Read 63624 times)

0 Members and 1 Guest are viewing this topic.

RobbeK

  • Guest
Re: TinyScheme
« Reply #210 on: September 13, 2014, 10:57:45 AM »
Thanks John, 

member of the gang now ,    ( robbek is the name there )

best Rob !! 

JRS

  • Guest
Re: TinyScheme
« Reply #211 on: September 13, 2014, 11:22:48 AM »
Quote
member of the gang now ,

Welcome to the Koding family!

Let me know if you need a hand with anything.

FYI: localhost = 0.0.0.0 in your VM.




JRS

  • Guest
Re: TinyScheme
« Reply #212 on: September 15, 2014, 09:22:05 PM »
Rob,

Curious if you were able to get all your favorite Lisp languages running on Koding.com in 64 bit?

John

RobbeK

  • Guest
Re: TinyScheme
« Reply #213 on: September 16, 2014, 01:14:23 AM »
Hi John,

Not yet ...   I have to finish something else first, but it is almost done ,  i'll update the moment been there


best regards, Rob

JRS

  • Guest
Re: TinyScheme
« Reply #214 on: November 14, 2014, 12:06:30 PM »
Rob,

I would like to experiment with the TinyScheme SB extension module generating statistical lists that the SB SQLite extension module would store. Finally I would like to use this stored SQL data to generate graphics with the SDL_gfx SB extension module. Maybe we can add some O2 DLLC magic to gain a little speed. Charles is already working on a table/matrix feature that might come in handy eliminating the SQLite part.

I gave your/Mike text Mandelbrot example a try since the rebuild of my Linux system.

Code: Script BASIC
  1. ' Character Mandelbrot
  2.  
  3. IMPORT ts.inc
  4.  
  5. sc = TS_New()
  6. TS_Cmd sc, "(load \"init.scm\")"
  7. mbrot = """
  8. (newline)
  9. (newline)
  10. (display "Ascii Mandelbrot TinyScheme") (newline)
  11. (display "---------------------------") (newline)
  12.  
  13. (define sq
  14.   (lambda (x) (* x x)))
  15.  
  16. (define (1+ x) (+ x 1))
  17. (define (1- x) (- x 1))
  18.  
  19. (define level
  20.  (lambda (i x y rc ic it orb)
  21.   (if (or (= i it) (> orb 4)) i
  22.    (level (1+ i) (+ rc (- (sq x) (sq y))) (+ ic (* 2 x y)) rc ic it (+ (sq x) (sq y))))))
  23.  
  24. (define mlevel
  25.   (lambda (L)
  26.     (level 0 (cadr L) (car L) (cadr L) (car L) 11 0)))
  27.  
  28. (define (main)
  29.   (let ((cnt 0) (lvl 0) (xo -1.7) (yo -2.3) (dz 0.1) )
  30.     (do ((i 0 (1+ i)))
  31.         ((= i 30))
  32.        (do ((j 0 (1+ j)))
  33.            ((= 30 j))
  34.              (set! lvl (mlevel (list (+ xo (* i dz)) (+ yo (* j dz)) )))
  35.              (if (< lvl 10)
  36.                   (begin (display lvl) (display " "))
  37.                   (display lvl))
  38.              (set! cnt (1+ cnt))
  39.              (when (= 30 cnt)
  40.                 (set! cnt 0)
  41.                 (newline))
  42. ))))
  43.  
  44. (main)
  45. """  
  46. PRINT TS_Cmd(sc, mbrot),"\n"
  47. TS_Close sc
  48.  

Output

jrs@laptop:~/sb/sb22/TS$ time scriba mbrot.sb


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.634s
user   0m0.629s
sys    0m0.004s
jrs@laptop:~/sb/sb22/TS$


The Script BASIC SDL_gfx extension module is also working fine. (see attached)

Code: Script BASIC
  1. ' ScriptBasic GFX - Alpha Bezier Curve
  2.  
  3. IMPORT gfx.inc
  4.  
  5. ' Random Value Arrays
  6. scrn = gfx::Window(640, 480, "Script BASIC SDL_gfx - Alpha Bezier")
  7. RANDOMIZE(gfx::Time())
  8. FOR i = 0 TO 512
  9.   rx[i] = RND() % 640/2
  10.   rxx[i] = 640/2 + rx[i]  
  11.   ry[i] = 60 + RND() % 480 - 80
  12.   lw[i] = 2 + RND() % 7
  13.   rr[i] = RND() AND  255
  14.   rg[i] = RND() AND  255
  15.   rb[i] = RND() AND  255
  16.   af = rx[i] / 640
  17.   ra[i] = INT(255 * af)
  18. NEXT
  19. ts = gfx::Time()
  20. FOR i = 0 TO 512-3 STEP 3
  21.   a1[0] = rxx[i]
  22.   a1[1] = rxx[i + 1]
  23.   a1[2] = rxx[i + 2]
  24.   a2[0] = ry[i]
  25.   a2[1] = ry[i + 1]
  26.   a2[2] = ry[i + 2]
  27.   gfx::bezierRGBA scrn, a1, a2, 3, 100, rr[i], rg[i], rb[i], ra[i]
  28. NEXT
  29. te = gfx::Time()
  30. gfx::stringColor scrn, 20, 15,"Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff
  31. gfx::Update
  32. WHILE gfx::KeyName(1) <> "+escape"
  33. WEND
  34. gfx::Close
  35.  

Another option is to use the new IUP GL Controls. This may be preferred as DLLC allows multi-threading IUP SB sessions with a common message handler able to call SB functions/subs.



Can you help fill in the holes with defining the model and generating the TinyScheme lists?

John

.
« Last Edit: November 14, 2014, 07:27:05 PM by John »

JRS

  • Guest
Re: TinyScheme (Chicken)
« Reply #215 on: November 14, 2014, 08:52:15 PM »
Rob,

I built the latest development release of Chicken on my Linux 14.04 64 bit box.


jrs@laptop:~/chicken-4.9.0rc1$ ./csi

CHICKEN
(c) 2008-2014, The Chicken Team
(c) 2000-2007, Felix L. Winkelmann
Version 4.9.0rc1 (rev 3cf1967)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2014-04-17 on hd-t1179cl (Linux)

#;1>


This looks interesting but I don't know how/where the IUP interface can be found.

Tutorial on the Iup Graphical User Interface toolkit

JRS

  • Guest
Re: TinyScheme
« Reply #216 on: November 17, 2014, 07:09:22 PM »
I was finally able to get the IUP GL Controls demo compiled on Linux. (with Antonio's help) There was a #ifdef causing skipping of code in the example.  :-\


jrs@laptop:~/sb/c_ode$ ./glcontrols
Vendor: Intel Open Source Technology Center
Renderer: Mesa DRI Intel(R) Ironlake Mobile
Version: 2.1 Mesa 10.1.3
ACTION_CB(gltoggle, state=1) NAME=toggle5
...


Has anyone heard from Rob lately?



.
« Last Edit: November 17, 2014, 09:19:45 PM by John »

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #217 on: November 17, 2014, 10:51:50 PM »
Quote
Has anyone heard from Rob lately?
Nope.

JRS

  • Guest
Re: TinyScheme
« Reply #218 on: November 17, 2014, 11:12:18 PM »
Mike,

I'm trying to bring TinyScheme and IUP GL Controls together for a GUI Lisp example. Do you have a TinyScheme example that would generate delimited lists that I could translate to a graphic representation? I was thinking the Mandelbrot iterator I converted as a SDL_gfx ext. module function to get started.

John

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #219 on: November 17, 2014, 11:29:23 PM »
Er, no John, I'm not that advanced in Scheme yet. But I think you can use Rob's ASCII Mandelbrot too if its output numbers are table mapped to distinct colors of some blobs (e.g. square or circular shapes) drawn on the IUP OpenGL canvas.

AFAIK there are no instruments in IUP to draw primitives per se (dots, lines, shapes, etc.), which means you will also have to provide some form of direct communication between your Scheme and the OpenGL library's API in order to be able to draw on the IUP OpenGL canvas. I'm not sure if TinyScheme has such functionality but I think Chicken should have it implemented by now.

This Chicken+IUP interface seems interesting. :)

JRS

  • Guest
Re: TinyScheme
« Reply #220 on: November 17, 2014, 11:34:12 PM »
I have to agree that the IUP OpenGL interface (other than their new controls) is raw. I'm better off sticking with SDL_gfx for the graphics interface.

Here is a very early attempt at using IUP canvas primitives to create a Mandelbrot Set.



Code: Script BASIC
  1. IMPORT iup.bas
  2.  
  3. Iup::Open()
  4.  
  5. ican = Iup::Canvas()
  6. Iup::SetAttribute(ican, "RASTERSIZE", "800x600")
  7. Iup::SetAttribute(ican, "BORDER", "NO")
  8.  
  9. dlg = Iup::Dialog(Iup::Vbox(ican))
  10. Iup::SetAttribute(dlg, "TITLE", "Mandelbrot Set")
  11.  
  12. Iup::Map(dlg)
  13.  
  14. ccan = CD::CreateCanvas(CD::ContextIup(), ican)
  15.  
  16. Iup::Show(dlg)
  17.  
  18. przelx = 3 / 800
  19. przely = 2 / 600
  20.  
  21. FOR x = 1 TO 800
  22.   FOR y = 1 TO 600
  23.     a = 0
  24.     b = 0
  25.     c = 0
  26.     x2 = (przelx * x) - 2
  27.     y2 = (przely * y) - 1
  28.     petla:
  29.     a2 = a * a - b * b
  30.     b2 = 2 * a * b
  31.     a = a2 + x2
  32.     b = b2 + y2
  33.     z = a * a + b * b
  34.     IF z < 4 AND c < 255 THEN
  35.       c = c + 1
  36.       GOTO petla
  37.     END IF
  38.     IF c = 255 THEN
  39.       pixclr = CD::EncodeColor(0, 0, 0)
  40.     ELSE
  41.       g = 255 - c
  42.       pixclr = CD::EncodeColor(g, g, g)
  43.       ' Color version
  44.      ' pixclr = (g+64) * g * (g+16)
  45.    END IF
  46.     CD::CanvasPixel(ccan, x, y, pixclr)
  47.   NEXT y
  48. NEXT x
  49.  
  50. Iup::MainLoop()
  51. Iup::Close()
  52.  

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #221 on: November 17, 2014, 11:49:02 PM »
I'm talking about general ability of whatever Scheme you use to call a shared object's API, and I'm not sure if TinyScheme is at all able to call alien C libraries (.so or .dll). OTOH I think Chicken can do it, so both IUP+SDL and IUP+OpenGL seem feasible: depending on your preference, you just create an IUP dialog window and assign an SDL or OpenGL canvas to it and then use the corresponding SDL or OpenGL API's to draw on it.

P.S. Oh, so you know how to draw on an IUP canvas or at least set pixels on it, don't you?
« Last Edit: November 17, 2014, 11:57:23 PM by Mike Lobanovsky »

JRS

  • Guest
Re: TinyScheme
« Reply #222 on: November 17, 2014, 11:58:21 PM »
I'm happy with the TinyScheme interface the way it works. SB will create TS functions and call them. The results (a string) will be SPLITA to an array and processed by SDL_gfx. (the plan anyways)

IUP has the CD (Canvas Draw) library you need to download separately.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #223 on: November 18, 2014, 12:03:32 AM »
Understood.

And thanks for the tip on Canvas Draw; it somehow slipped my attention.

RobbeK

  • Guest
Re: TinyScheme
« Reply #224 on: February 08, 2015, 04:18:31 AM »
TS and foreign functions :


https://github.com/ignorabimus/tinyscheme-ffi


best, Rob