Showing posts with label scheme. Show all posts
Showing posts with label scheme. Show all posts

Webgl and scripts

As an homage to the MIT open courseware and in the spirit of openness, I am making a scheme language method which takes the MIT course and analyzes the video to produce an ogg soundtrack synchronized to a synthetic video which is OpenGL implementation of the movement of the professor and synchronized with the audio. The stick man is my SVG stick man that I use for my comics. I have considered texturing the face with the image of the prof, but decided against adding extra bandwidth. The net bandwidth to have the course on video is very small and since it is XML scripted, it is editable to create a new video with a text editor. By chunking and connecting sentences to explanations it is possible to slice and dice the whole thing and use glrotate, glscalef, gltranslate and other functions to coordinate the synchronization of video and audio with models. Using a WebGL like interface it is possible to simply pipe commands like pan and zoom or fade. Actually it could be viewed as 3D over the web or piped to blender. Just some fun while trying out some more complicated scheme scripts.

This image is from the book "Structure and Interpretation of Computer Programs". It is the founder of MIT, William Barton Rogers.


This is just for grins and it is a merger of MakeHuman and a WebGL with Python template for a plasmoid which communicates a synthetic video and uses espeak with a scripted character activated by openGL modified vertices.

A scheme to create Pythons

Tonight I hope to complete the entire MIT book on scheme in detail. Here is a link to an on-line version. I have programmed with scheme and interfaced to gimp with scheme methods. It is my intent to write a simple scheme program that implements an interpreter that in turn replaces the scheme interpreter to scale to a complete system. Syntactically it is very simple and the complexity is encountered at the level of complex applications. This is typical of all languages and systems that I have encountered. What I hope to gain is an idea about ways to improve the flexibility of a system by creating a core that adapts to additional methods in a way that is extensible. At least that is one of my goals, the other is to create a script converter to Python or C. λ is a symbol commonly used to represent scheme, however there is significant key symbol over loading there as it is typically used to represent the wavelength of light (i.e. λf=c) and many other things in context. So I will say programming.λ if the context is ambiguous.

The significant elements of the book will be added here:

The overall process reminds me of many things, including my early days of BAL ( IBM machine language ) ( H-I A-B L-M 9000 , Yes Dave? ( I didn't lock you out in space and you never built a space ship and it is 9 years after 2001, so who is really to blame for that?)) Thus HAL=IBM -1 corresponding ASCII. CDR,CAR, ZAP, ... It may be that the approach is just not complete because the concept of the implementation is improperly structured. I will consider that. It seems unusual that if I have a computer that can search a dictionary and understand spoken commands, why would it be necessary to use if( gamma==beta){} when a preprocessor is quite capable of allowing the specification of action at a near English level and the interface need not be so arbitrarily obtuse. It would seem that it could be done as this :

#define "is mathematically equal" ==
, or some such. I am considering what might make more sense and still be familiar to myself and others, while allowing an equivalent more precise and natural interface to the process control.

Something that is very intriguing is the implementation of a logic solver for the Kalotan puzzle and others. There is something that is hidden in the implementation of the solution that is possibly as useful as the concept definition of certainty. I grasp the logic of the implementation of the solution and that is enlightening. It is an interesting concept as a whole that a sequence of methods and their product can be indeterminate or decided by conflicting results that imply that either the assumptions and/or premise are failed or the situation itself is impossible. [PlaneT Scheme](sic) is also very interesting. The Internet is a dream come true for a polymath. I think that Isaac Newton or Archimedes would faint if they had these kind of tools.

One of the problems that is encountered constantly in all areas of programming and science is pre-requisites. The problem of dependency is everywhere. One of the problems that is rarely discussed is that many programs have library dependencies or environment, or even machine architecture dependencies that are the greatest part of what is needed to achieve a certain goal. Understanding library dependence and usage along with knowing what subjects must be understood before attempting to understand or implement a specific task is one of the most important foundational talents IMHO.

It seems there are a lot of interesting things to learn relating to scheme which seem to be implemented in a rather prehistoric way. The concepts are no less valid, however it needs to be extended for the 21st century. Some of the relationships need to be integrated with other tools. I will try to make some images or blends to express what can be done with the interface. There are some relationships between Spice and integrated circuit design that seem a good fit.

( Not ( Accepting ( Infinity - x ) ( AI ) ) )

In the course at the link from Berkeley computer science about scheme, it is not as elegant as other courses in Lisp like languages ( most I have seen at MIT and Stanford ), but I feel it gets to the heart of the matter and I will attempt to dig deep and find reason here.

A language such as this defines functions which have data. Essentially it is f(x), where x is anything and f is a method. I could implement this as push x, call f, and that would be it. I can interpret the language any way I want. I can parse from "(" to ")" and select element 1 as function and then push push the rest. I compare syntax and then generate a function call corresponding to my interpretation of syntax. At its most basic level it is an operation on registers when dealing with CPU functions and I could assign opcode xx to be "mov" or "add" or "xor" or even "doodoo" if I wanted. The mnemonics and symbolism are unimportant.

If you start with infinites and then focus on partial infinites then you have a system of math and logic which is provable and complete. A person can device any number of circularly perfect systems and religion is one of those. I can start by asking you to assume one fact and then based on an assumption devise a complete system. That is an unfounded logic system and the system of math is an unfounded system. I am asked to assume 1 (one) and I cannot accept that, as odd as that seems.

The proof of pudding is in eating and the proof of a proper system is in its foundation in the universe. In the biological system it is a complex of infinities and each part affects every other part. I could be true that the structure which defines the hand could influence the nature of the brain. It is a system without limit and it is true that seemingly unrelated elements of a person's physical whole influence certain "metaphysical" aspects. A dog may not bark by design, but by his paws.

I am sure that is as clear as mud, but I hope to relate some example methods and systems that make the concept clearer.

Debian has a package for scheme called "mit-scheme" and it executes at command line with the command `scheme`. I suppose that the failure to use arrow keys is some compatibility issue and I can live with that.

Scheme of things

I add a little color to the concept of interfacing using scheme or `guile` or Kawa or a Lisp like language. I personally have an easier time dealing with the code when it is highlighted with color in `kate`. The output is nothing special but it works and that means it is a base case I can extend and test and always revert to see what I screwed up if it fails. Also I wanted to conceptualize CDR and CAR and CONS. It all relates and this does have something to do with trees and matrices and solutions. The sum of the parts is something else and just develops. I suppose it could be something that I could say is "glympisifith"[sic] or some other made up word to reference the complete system, but I don't think people can communicate at that level.


I had said that I would delve deeper into scheme and ".scm" scripting and how it gets integrated in a program and how the scripts actually execute. I have a queue that keeps all the things I must complete and they get pushed and popped all the time. When I am at a dead end to understand something I pop the process and solve the relationships so that I have that dependency satisfied and continue toward the goal. So today I had to pop scheme, guile, Lisp and that category so I could understand how these things relate. I also have to do the same thing with Python+blender along with Python+gimp and ".scm" with many things.

The basic template for this came from GNU here. I didn't find it so clear how all the pieces got assembled and perhaps the person who wrote that tutorial thought they were being very clear, but I did not find it so. This code compiles and runs on my machine. It just makes a box. The point is not to have an elegant application, but to identify the nuance of interfacing (language A) with (language B).


#include <libguile.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> static double x, y; static double direction; static int pendown; /* Simple backend for a Logo like tortoise drawer. */ static const int WIDTH = 10; static const int HEIGHT = 10; static FILE* start_gnuplot () { FILE* output; int pipes[2]; pid_t pid; pipe (pipes); pid = fork (); if (!pid) { dup2 (pipes[0], STDIN_FILENO); execlp ("gnuplot", NULL); return; /* Not reached. */ } output = fdopen (pipes[1], "w"); fprintf (output, "set multiplot\n"); fprintf (output, "set parametric\n"); fprintf (output, "set xrange [-%d:%d]\n", WIDTH, WIDTH); fprintf (output, "set yrange [-%d:%d]\n", HEIGHT, HEIGHT); fprintf (output, "set size ratio -1\n"); fprintf (output, "unset xtics\n"); fprintf (output, "unset ytics\n"); fflush (output); return output; } static FILE* global_output; static void draw_line (FILE* output, double x1, double y1, double x2, double y2) { fprintf (output, "plot [0:1] %f + %f * t, %f + %f * t notitle\n", x1, x2 - x1, y1, y2 - y1); fflush (output); } static void tortoise_reset () { x = y = 0.0; direction = 0.0; pendown = 1; fprintf (global_output, "clear\n"); fflush (global_output); } static void tortoise_pendown () { pendown = 1; } static void tortoise_penup () { pendown = 0; } static void tortoise_turn (double degrees) { direction += M_PI / 180.0 * degrees; } static void tortoise_move (double length) { double newX, newY; newX = x + length * cos (direction); newY = y + length * sin (direction); if (pendown) draw_line (global_output, x, y, newX, newY); x = newX; y = newY; } static void* register_functions (void* data) { return NULL; } int main( int argc, char *argv[]) { int i; global_output = start_gnuplot (); //scm_with_guile (&register_functions, NULL); //scm_shell (argc, argv); tortoise_pendown (); for (i = 1; i <= 4; ++i) { tortoise_move (3.0); tortoise_turn (90.0); } }


# Basic Makefile for the tortoise package. CFLAGS = `guile-config compile` LIBS = `guile-config link` .PHONY: clean build run build: tortoise clean: rm -f tortoise tortoise.o run: tortoise ./tortoise tortoise: tortoise.o gcc $< -o $@ $(LIBS) tortoise.o: tortoise.c gcc -c $< -o $@ $(CFLAGS)

So I get the concept now and `guile` is a bit more understandable in the concept of a universal constructor. I have the framework now and I can fill in easily now from other languages as everything is pretty much the same when you program. I prefer assembly language but it isn't the do all and end all of getting things done, it is just more predictable for me as I am essentially switching gates to get the result I want and in that way I can make it virtually deterministic.

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen