id
stringlengths 2
6
| revid
stringlengths 1
7
| url
stringlengths 40
44
| title
stringlengths 2
253
| text
stringlengths 140
975k
|
|---|---|---|---|---|
323206
|
147
|
https://en.wikiversity.org/wiki?curid=323206
|
Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory 5
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, evaluation, tools, repository.
Texture handling.
Usage.
The following code can be found in the SVN repository, in the examples folder as example-08.
Mapping a texture onto a sphere.
More details on how to programmatic build a sphere and how texture coordinates are binded can be found here: [Parametric Equation of a Sphere and Texture Mapping (broken link)]
The following code can be found in the SVN repository, in the examples folder as example-09.
While this technique is general and can be used to load all sorts of textures, there are cases in which it is not sufficient. One example is related to sphere mapping. Let's say we have a sphere representing a planet on which we want to apply a texture representing the planet's surface.
However when applying a texture on a sphere in this way, you will notice that the sphere is lighted in the same way anywhere. In order to produce the correct light effects one needs to enable sphere mapping by using GL_SPHERE_MAP:
When applying sphere mapping, however, the texture will be drawn so that its center will always face the camera, prohibiting the rotation of the texture on the sphere.
Model loading.
Sometimes it is useful to create objects outside the OpenGL environment, but to be able to use them afterwards in our applications.
One way to accomplish this is to create our models with 3D Studio Max and export them as .3ds files. (Or to create them using any other application that can export such files.) And in order to import them we must write a parser that understands the .3ds files, and transforms them into a stream of OpenGL primitives -- points, lines, and simple surfaces.
Another way is to just use an existing .3ds parser, like the one provided in the project JOGL Utils.
JOGL Utils.
Usage.
The following code can be found in the SVN repository, in the examples folder as example-07.
Models.
You could find .3ds files on the internet by a simple search query: http://www.google.com/search?hl=en&q=free+3ds+models
Assignment.
This is the fifth assignment, so please commit it to the folder "assignment-05".
Create a simple OpenGL application that creates a cube and adds one texture for each of the faces (each face should use a different texture).
|
323211
|
147
|
https://en.wikiversity.org/wiki?curid=323211
|
Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory evaluation
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, evaluation, tools, repository.
Administrative issues.
At the beginning of each laboratory you will receive an assignment, which should be completed -- individually -- during the two hours. At the end of the laboratory each student will upload the resulting source code on the SVN repository. Those who are not present, or those who didn't manage to finish, have the possibility to upload the source code until the end of the week.
We shall do our best to provide the laboratory notes (including the assignment) a week in advance.
For each assignment a grade will be given from 0 to 10, following the following guidelines:
The attendance is mandatory for at least 75% of the laboratories.
The final grade for the laboratory is a weighted sum of the assignment grades, scaled from 0 to 10, but if a student does not meet the mandatory attendances, his grade will be logarithmically proportional to the number of attendances.
Technical issues.
In order to optimize the evaluation process the following constraints apply:
Failing to comply with the above constraints might render your assignment into a non-running one, thus affecting the grade.
Projects.
There exists also the possibility to develop a project instead of the weekly assignments and the mandatory attendance. Those interested in a project should contact their laboratory assistant and establish together with him the project requirements. Please note that the project should be a complex one -- at least 24 hours (= 3 days) of work -- and there must be some meetings to discuss the project status (about 25-30% of the laboratory count).
|
323212
|
147
|
https://en.wikiversity.org/wiki?curid=323212
|
Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory tools
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, evaluation, tools, repository.
Java.
Please consult .
Eclipse.
Please consult .
Subversion.
Please consult .
|
323213
|
147
|
https://en.wikiversity.org/wiki?curid=323213
|
Computer graphics -- 2007-2008 -- info.uvt.ro/Subversion repository
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, evaluation, tools, repository.
Purpose.
All your source code and needed data (libraries, textures, files) (or in case of an essay the documents) for an assignment should be placed in the Subversion repository provided by us.
The usage of the Subversion repository has the following advantages:
Usage.
In order to use the repository you need the following information:
You should also be familiar with the clients and plugins:
Please be careful about the username. In our case the username is all lower-case letters, and some clients pre-fill the username with the current operating system user. If the casing differs please correct, or else you will encounter SVN authorization errors. If you have made this mistake, then you must find the folder "Documents and settings" / "your folder" / "Application data" and here identify the "Subversion" folder which you should delete. After this restart Eclipse and carefully reenter the username and password.
Repository layout.
Each student has at its disposal a folder which contains subfolders for every assignment. Thus the assignments should be placed only in these subfolders.
Example repository layout:
You should never attempt to checkout the entire repository. Usually you should only checkout the specific folder for an assignment (like "assignment-01").
Subclipse short tutorial.
This is a small guide that will guide you into using Subclipse plugin together with Eclipse. It covers:
Installation.
Please consult: .
Commit.
Please consult: .
Update.
Please consult: .
|
323214
|
147
|
https://en.wikiversity.org/wiki?curid=323214
|
Computer graphics -- 2008-2009 -- info.uvt.ro
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
Classes.
The laboratories presented here follow the ones from Computer graphics -- 2007-2008 -- info.uvt.ro. However there are some modifications related to
their content and thus students are encouraged to follow these ones instead.
The materials for the CG class can be accessed at this page (by Prof. Dr. Dana Petcu (in Romanian)).
Laboratory agenda.
Please consult Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory agenda.
Laboratory evaluation.
During each lab you will be given some problems to solve. At the end each of student will report his/hers progress and during the next laboratory a number of 3-5 students will be randomly picked for questioning on their assignments. The students will be graded for each answer (on a scale of 1 to 10) and the final lab grade will be the average of their obtained grades.
The lab grade makes up 50% of the final grade.
No other examination form will be considered (projects, homeworks, tests during the semester).
Laboratory tools, frameworks and libraries.
Please consult Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory tools.
You can find application templates for starting your own JOGL application at the following link: Computer graphics -- 2008-2009 -- info.uvt.ro/JOGL-Template.
|
323217
|
147
|
https://en.wikiversity.org/wiki?curid=323217
|
Computer graphics -- 2008-2009 -- info.uvt.ro/JOGL-Template
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
Complete example.
Two example templates are given here. One for scenes using an orthographic projection and one for scenes using a perspective projection.
These examples are intended to be used as templates for future JOGL based applications.
|
323219
|
147
|
https://en.wikiversity.org/wiki?curid=323219
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 10
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
World Box.
The world box is nothing else than a simple cube (sphere) which contains all of the scene's objects as well as the camera. The following constraints must be met:
World boxes are used to add realism to our environment by showing distant mountains, clouds, star fields. Generally they are used to in the scenes objects that are to far from us and thus cannot be reached (near the horizon).
Important: when drawing the world box we should note that it must be drawn, so that the face polygon is on the inside!
Using glDrawArrays and glDrawElements instead of glVertex*, glNormal* and glTexCoord* methods.
Instead of drawing every vertex, normal and texture coordinates we can directly use an array of elements and dereference them by indices. This approach has several advantages including: minimising both the code length and the memory space by not duplicating shared vertices.
The following example shows how we can draw a cube using "glDrawElements":
Normals and texture coordinates can be added in the same way by using arrays mixed with "glNormalPointer" and "glTexCoordPointer":
NOTE: For a cube, normals and texture coordinates cannot be shared! So the indices must go from 0 to 23 instead of 0 to 7.
Links:
Object Collisions.
Collision detection allows programmers to simulate solid objects through which nothing can pass. It is useful in simulating physical laws. For example we could simulate a billiard game or a projectile which explodes when hitting a surface.
One of the simplest techniques involves surrounding each body (including the camera) with either a sphere or a cube. For simplicity we will use a sphere. The following steps detail how we could create a rudimentary collision detection mechanism:
Important:The previous logic should be applied each time a frame is drawn and for small steps of object/camera movement otherwise we could end up passing through an object without detecting the collision. Additionally we could check in advance if two objects would collide by computing their future positions and apply the previous logic.
To avoid passing through an object as previously stated we first need the following (given two spheres P and Q):
Given the above we can compute the position at moment "t" as:
The distance at moment "t" can be then computed as:
where "A = Pi - Qi" "B = VP - VQ"
The time of collision t can be computed as follows:
t = (-A*B - sqrt((A*B)^2 - B^2 * (A*A - (a + b)^2))) / B^2
If t is inside the interval [0,1) then a collision occurs during this time frame.
NOTE: A*B means the scalar product between A and B. The result is a scalar and is given by (Ax*Bx + Ay*By + Az*Bz)
Links:
Exercise.
NOTE: Use "glDrawArrays" and then "glDrawElements" instead of "glVertex*" to render the world box cube.
NOTE: For collision detection in the case of the 3D simulator (Exercise 1) the first sphere is always the camera and the second sphere could be any object in the scene. Use "moveCamera" together with "cameraCoordsPos*" to compute the current position and the position at the next step of the camera. You may need additional the "tmp" vector inside the "moveCamera" method to get the direction vector.
|
323223
|
147
|
https://en.wikiversity.org/wiki?curid=323223
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 14
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
Brief introduction in Managed DirectX 9.
Overview.
In this lab we will discuss some general issues concerning with the creating of a simple DX scene and the draw of certain elements inside of it. The code will be written in C# as it closely resembles Java.
NOTE: This lab is only intended to provide a quick intro to Managed DX and comparison with OGL and must not be seen as a tutorial by itself.
Creating a simple Hello World application.
Before proceeding we need to add references to the DirectX libraries which we are going to use. For this go to the Project menu, and select "Add reference". In the list that comes up, pick "Microsoft.DirectX" and "Microsoft.DirectX.Direct3D". Also add the following lines to you using-block, so your program can use the referenced libraries:
Each Managed DX application basically requires:
Additionally we could require some user interaction by using the mouse, the keyboard, the joystick etc.
Initialization of the DX device.
Initialization of the DX device is usually done inside a custom built method which needs to be called before rendering the scene. The next fragment of code shows how we can achieve this:
Rendering.
Rendering a DX scene requires overriding the OnPaint method:
Device resetting.
The OnResetDevice event handler is a good place to create and initialize any Direct3D related objects, which may become invalid during a device reset:
Projection and ModelView in Managed DirectX.
As (J)OGL, DX also comes equipped with methods for dealing with setting up a projection, model (world) and view matrix. Both of their methods are quite similar:
NOTE: The previous code created a "perspective projection". Additionally one can create an "orthographic" one by using the Matrix.OrthoOffCenterLH, Matrix.OrthoLH methods or their RH (right hand) counterparts.
The model matrix can be manipulated in the same way as in (J)OGL by applying rotations, translations and scaling on the scene objects. The following fragment of code shows how we can achieve these:
Dealing with vertices.
As (J)OGL, DX relies on vertices as the building blocks of the scene elements. In contrast to (J)OGL DX vertices can be defined in multiple ways: as "transformed" (screen coordinates), "untransformed" (world coordinates), with "textures" or with "colors" etc:
The primitives which can be built from vertices are also similar with the (J)OGL ones:
The following code fragment show how we can build triangle from PositionColored vertices:
Similar with OGL's display lists DX offers VertexBuffers. A vertex buffer can be created as follows:
IMPORTANT: Lighting must be off if we want our primitives to be visible. If using lighting we need to specify normals to our vertices (use PositionNormalColored, PositionNormalTextured etc.).
Lights, Materials and Textures.
The following fragment of code shows how we can add lighting, materials and textures to scene objects.
Adding spheres to the scene.
Spheres are some of the easiest 3D objects to draw in either OGL (using GLU) or DX. The following example shows how we can add a sphere to a scene and add a material and texture to it.
Blending.
Blending usually means mixing color components of several objects in the scene. DX achieves this as easily as (J)OGL:
Other issues.
The previous sections were meant to show how we can achieve in DX most of the things shown in the previous (J)OGL laboratories. However they were not presented in much detail.
However topics such as "camera movement", "particle engines", "world boxes" were omitted as they can be easily achieved with the already known issues plus some translation of OGL code to DX.
|
323225
|
147
|
https://en.wikiversity.org/wiki?curid=323225
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 4
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
(J)OGL BASICS (PART 3).
NOTE: Grab the application template from the following link: Computer graphics -- 2008-2009 -- info.uvt.ro/JOGL-Template
Textures.
A texture is a rectangular array of data containing information about color, luminance, color and alpha. Each element in this array is called a texel.
Textures can be 1D, 2D or 3D (used to simulate certain characteristics in the material they depict)
Texture mapping allows one to glue together an image of an object on a polygon. For example images of walls, vegetation, landscapes, etc. NOTE: besides being applied to polygons textures could be also applied to other primitives such as points, lines, polygons, bitmaps and images. It implies mapping texture coordinates to geometric coordinates.
NOTE: you can download textures from the following link: .
Links:
Creating and displaying 2D textures.
The steps involved in generating a 2D texture are as follows:
NOTE: an alternate method for generating textures by using the Texture and TextureIO classes is presented at the following link: Computer graphics -- 2007-2008 -- info.uvt.ro/Laboratory 5.
Important: texture size must be a power of 2 (32x32, 64x64, 512x128, etc) for the texture loader to work properly. Failing to provide a power of 2 texture size will result in an error.
The following code fragments exemplifies the previous steps (IMPORTANT - Please be sure to download and copy the classes found inside the following arhive: https://staff.fmi.uvt.ro/~marc.frincu/TextureManager.zip):
NOTE: While the previous code reads textures from image files, the textures can also be generated by specifying the pixel matrix. This (uses glTexImage2D) and this (uses glDrawPixels) exemplifies how you can achieve this.
Textures can also be repeated or clamped:
The previous techniques are useful when one decides to give texture coordinates outside the [0, 1] interval.
Links:
Replacing parts of a texture with another.
(J)OGL allows one to replace parts of a texture with another. This technique is also used for improving performance as replacing a texture is much faster than rebuilding it each time.
The following code fragment shows how one can replace a texture with another. Be sure to generate 2 textures inside init, and change "NO_TEXTURES = 1" with "NO_TEXTURES = 2" inside your code before testing it.
NOTE arguments 3,4,5 and 6 from the "glTexSubImage2D" represent the position in pixels (arguments 3 and 4) from where a portion of given width (argument 5) and height (argument 6) will be replaced by the pixel data given as last argument. The width and height need to be smaller than the initial image size (tex[0].getWidth, tex[0].getHeight - in our example). The coordinate center (0,0) is situated in the lower left corner of the image.
Links:
Anisotropic Fitering.
Mipmapping often produces blurred images for distant textures viewed at oblique angles. This is due to the fact that texture mapping mode assumes the texture space is a square (isotropic) while in reality it is rather long and narrow (anisotropic). To overcome this problem one could apply anisotropic filtering as detailed in the following code fragment:
Texture transparency and blending.
Blending means combining two or more textures by mixing their components.
Transparency means making some pixels transparent. The transparency factor can range from opaque to fully transparent.
Steps for blending.
Note: (for 3D graphics) there are cases when you need to disable the depth test while blending, by using the glEnable(GL_DEPTH_TEST) and glDisable(GL_DEPTH_TEST) functions (methods)
Steps for transparency (alpha testing).
IMPORTANT: In order to enable blending we need two textures. As a result the code fragment in the init method for creating a texture needs to be duplicated:
NOTE: The previous method is inefficient as it requires one to copy several lines of code multiple times. A better approach would be to create a class for handling texture creation and manipulation (binding, enabling, disabling).
Links:
Exercises.
NOTE: Use the TextureHandler that you implemented for the first assignment in the rest of the exercises!
|
323227
|
147
|
https://en.wikiversity.org/wiki?curid=323227
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 5
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
2D GRAPHICS BASICS (PART 4).
Placing text in your scene.
In (J)OGL one can place text at certain coordinates (2D or 3D). This is easily achieved by using the GLUT API.
The method (function) intended for displaying text is glutBitmapString.
Important: it should never be placed inside a "glBegin"/"glEnd" block.
Before using it we need however to specify the "raster position" (used to position pixel and bitmap write operations) by using the glRasterPos method (function). The object coordinates presented by "glRasterPos" are treated just like those given with "glVertex" methods (functions).
2D Application Example.
Simple Star Chart.
In what follows we will put together what we have seen so far and create a simple 2D application which displays a Star Chart.
A Star Chart is basically a projection (using for example the "Polar Projection") of constellations, stars and other stellar objects on a screen (paper).
To do this we need an API for reading and computing the coordinates of our objects (constellations, stars, names) from some data files.
A simple API which does the previous can be found here.
The next code fragment shows you how you it could be used:
Links:
PUBLISHING YOUR JOGL APPLICATION.
Usually you will want to make your JOGL application available to everyone. The simplest way to achieve this is to publish your application on a website either as an applet or as a Java Web Start application. For JOGL this is probably the way any developer does. Next we will address the second issue as it allows you to download and run signed application directly on your computer without requiring an active browser.
Java Web Start.
Java Web Start (or better known as javaws) allows user to start java applications directly from the Internet by using a browser as an intermediary. A specific requirement is for applications to be signed by trusted authorities. In contrast to applets, javaws eliminates some of the security restrictions of the former and thus lets applications perform operations such as file manipulation.
In order to deploy a javaws you need to do the following:
IMPORTANT The build from 24 April 2012 does not work. It gives an exception stating it cannot find the GLEventListener class.
Please use an older version of the JOGL, e.g., http://jogamp.org/deployment/archive/rc/v2.0-rc5/jogl-all-awt.jnlp. The next code fragment advices you on how to proceed if you get this error:
NOTE: we can notice that the JOGL jars are grabbed at runtime from the site. In this way we need not bother moving them also to the web server
NOTE: You do not need to restart your web server each time you modify the jar.
IMPORTANT: When reading files be sure to use an "InputStreamReader" as follows, or the application will not work:
Links:
Exercises.
IMPORTANT: remember to modify the "initialize*" methods by using:
instead of:
when reading the files.
IMPORTANT: place the "images" and "data" directories inside the "bin" directory for the application to work with JavaWS
|
323228
|
147
|
https://en.wikiversity.org/wiki?curid=323228
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 6
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
3D GRAPHICS BASICS.
Note For this lesson you will need to apply textures on your objects. The API from the following link could be useful in this direction. The main class is represented by "TextureHandler" which you were asked to implement during Laboratory 4. Place the Java classes in your "src" folder and use them as follows:
Perspective Projection, Depth and Shading.
Perspective Projection.
3D Graphics offers the possibility to simulate depth by using the Z axis. In order to obtain a realistic scene one should use the perspective projection instead of the orthographic one. The template for the perspective projection can be found at the following link Computer graphics -- 2008-2009 -- info.uvt.ro/JOGL-Template. The perspective projection can set up by using one of the following two methods (functions):
In what follows we will use the gluPerspective method (function).
IMPORTANT: The following code is part of the JOGL template for perspective projection. You do not need to paste it in the application.
Depth and Shading.
Depth (objects should obey the projection laws and cover (hide) one another -- based on the position relative to the viewer) can be enabled by enabling the GL_DEPTH_TEST state variable and selecting a depth function with the aid of the glDepthFunc method (function). In addition the shading model can also be set to further refine the 3D view:
Additionally when the "depth test" is enabled we must also clear the GL_DEPTH_BUFFER each time the scene is redrawn:
Links:
Looking at the scene from an arbitrary point of view.
There are cases when one needs to look at the scene from a particular point and towards another one. For this case there is the gluLookAt method (function) which allows the user to orientate the viewport.
The arguments for the gluLookAt method are:
NOTE: the gluLookAt method should be placed right after the "gl.glLoadIdentity" call in the display method.
Drawing simple 3D objects.
OGL does not offer methods (functions) for rendering (3D) complex objects such as spheres, cubes, pyramids, human faces, buildings, landscapes, etc. In order to simulate them one needs to implement its own library or use already existing ones such as GLU:
The following example shows how one can draw a sphere by using the GLU library:
Applying textures on 3D objects.
Applying textures on 3D objects is basically the same as for 2D ones. One notable difference arises in the case of spheres.
Mapping textures on spheres.
More details on how to programmatic build a sphere and how texture coordinates are binded can be found here: [Parametric Equation of a Sphere and Texture Mapping]
While this technique is general and can be used to load all sorts of textures, there are cases in which it is not sufficient. One example is related to sphere mapping. Let's say we have a sphere representing a planet on which we want to apply a texture representing the planet's surface.
However when applying a texture on a sphere in this way, you will notice that the sphere is lighted in the same way anywhere. In order to produce the correct light effects one needs to enable sphere mapping by using GL_SPHERE_MAP:
Note: When applying sphere mapping, however, the texture will be drawn so that its center will always face the camera, prohibiting the rotation of the texture on the sphere.
Lighting and materials.
3D Graphics also relies on lighting and materials to simulate surface features.
Lighting.
Light is what makes our scene (the objects) visible and has an important role in creating the illusion of 3D through the way in which "vertices" are lit. For example in the case of a sphere we might have a lighter area, corresponding to the point where the intensity of the light is greatest, and a diminishing effect towards the outside of that area. Of course this is also influenced by the materials used when drawing the objects (more on materials will come bellow). Without lights our objects will look like plain 2D objects!
The light that reaches your eye from the polygon surface arrives by four different mechanisms -- thus different light types:
Also in order to use lights first we have to be enable the feature with glEnable(GL_LIGHTING). However, this is not enough as we must still define and enable each particular light used inside a scene (at least 8 are supported on all video cards). This can be done using glLightfv which allows us to specify:
Important: When lighting is enabled, OpenGL suddenly needs to know the orientation of the surface at each polygon vertex. One needs to call glNormal3f for each vertex to define the normals of the vertices.
NOTE: By default the position of the light as specified when using GL_POSITION is {x, y, z, w} = {0, 0, 1, 0}.
NOTE: Light position is specified in homogeneous coodinates. This also effects the way a light is being treated.
IMPORTANT: Specular light might not work when using a texture on an object. This article discusses this issue and how it can be solved.
Links:
Materials.
As said before materials and lights are essential to each other, and there are some important things we need to know before proceeding:
On the other hand we can use the other alternative by calling glMaterial* commands before actually drawing the object, and thus being able to setup color and light handling. The next example illustrates this by drawing a yellow glowing sphere
Important: specifying the material properties has a different meaning than in the case of light properties. In the case of materials the RGB components specify the percent of color being reflected while in the case of lights it specifies the percent of color being emitted.
One could also use two new methods called glPushAttrib which takes one parameter: a mask that indicates which groups of state variables to save on the attribute stack, and glPopAttrib. More information here. For example we could store the GL_CURRENT_BIT which contains data about:
Links:
Exercises.
"NOTE": The objects could be too big for the viewport or might be situated outside of it. Use the glLookAt method (function) to fix the problem.
"NOTE": Normals should be added for each face of the cube, otherwise lighting won't work properly. You need to compute them manually and set them via the glNormal3* methods.
|
323229
|
147
|
https://en.wikiversity.org/wiki?curid=323229
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 7
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
USER CONTROL.
Keyboard and mouse control.
User input is very important especially in interactive graphic applications such as games or simulators by allowing the user to control the camera or interact with objects in the scene in real time. Usually this is done through the use of a keyboard and a mouse, and occasionally through a joystick, microphone (voice commands), or other input device.
If we want to be informed of keyboard an mouse events we have to register specific listeners besides the GLEventListener:
These issues are AWT specific, thus they are assumed to be known. You could find more information at the following links:
Please pay attention as the mouse coordinates are given in the view-port coordinates -- that is how we obtain the number of pixels from left and top -- and we must transform them in the object coordinates.
Important: OpenGL applications require the user to handle keyboard and mouse events in a different thread that the one on which it is performing the OpenGL operations as these operations cannot occur directly inside the mouse or keyboard handlers. A mouse or keyboard listener may invoke the "GLDrawable" instance's "repaint" method thus forcing the redisplay.
Links:
In order to enable your JOGL application to handle mouse or keyboard events you need to implement several interfaces:
The following fragment of code exemplifies the previous:
MORE ON MODELVIEW MANAGEMENT.
The scene in (J)OGL is manipulated by using the ModelView Matrix Besides this matrix the Projection Matrix is used for defining the viewing volume.
Revisit Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 2 for more details.
Next we will learn about how we can transform our scene and more precisely how we can move, scale or rotate objects. To do this first we need to remember that (J)OGL uses 4x4 matrices to store scene information. We can always choose to save the current matrix by using the glPushMatrix method (function) which pushes the current matrix on the stack. In the same way calling glPopMatrix method (function) retrieves the last saved matrix. This is useful for example when we want to draw planet Earth in orbit and then draw the Moon around it.
Model.
Transformations: Rotation, Translation, Scaling.
Model transformations involve rotating, scaling or translating objects in your scene.
IMPORTANT: One has to pay attention to the order these transformations are applied as a translation after a rotation does not produce the same effect as a rotation followed by a translation.
(J))OGL puts at the programmer's disposal a couple of very intuitive methods (functions) for handling object transformations: glRotate*(angle, x, y, z), glScale*(factorX, factorY, factorZ) (for values inside the (0-1) interval the object gets scaled down) and glTranslate*(x, y, z).
IMPORTANT: In (J)OGL the operations need to be placed in the code in the opposite order than in reality. For example a translation followed by a rotation in real life, is represented in (J)OGL as a rotation followed by a translation. See this for details.
For example the next fragment of code places a sphere at the center of the screen and makes another one rotate around it. It also explains how glPushMatrix and glPopMatrix methods (functions) work:
Viewing.
Camera control.
An important feature in 3D graphics is the ability to control the camera. This ability allows the user to navigate through the scene, zooming in objects, avoiding others, orienting himself in space, etc.
There are basically two ways of controlling your camera:
Solution 2: Use the "gluLookAt" method to re-orientate and reposition the camera.
For those interested we also show the solution for the "second variant" in which we use the "gluLookAt" method to re-orientate and reposition the camera.
The following code fragment shows how we can define methods for handling the moving and aiming of the camera. An additional the polarToCartesian method is used to convert polar (spherical) coordinates to Cartesian coordinates. The aimCamera and moveCamera methods are being called inside the display method at the beginning just after the glClear method call:
IMPORTANT: By default if azimuth and elevation are set to 0 then the camera is oriented parallel with the positive Z axis towards infinity.
|
323231
|
147
|
https://en.wikiversity.org/wiki?curid=323231
|
Computer graphics -- 2008-2009 -- info.uvt.ro/Laboratory 9
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, JOGL template.
USING COMPLEX OBJECTS.
There are cases in which the objects we need to draw are to complex for us to draw them ourselves. In such cases (J)OGL allows us to load object models generated by using various tools such as "3D Studio Max" (.3ds files). Other formats include .md2, .md3, .obj, etc.
Importing these custom made objects requires a parser. Usually the developer has to create himself or use an existing API (JOGL Utils). which transforms the file into a stream of OpenGL primitives -- points, lines and simple surfaces.
JOGL Utils.
Usage.
Rendering the model.
NOTE: You can find .3ds files on the internet by a simple search query: http://www.google.com/search?hl=en&q=free+3ds+models or try the examples from the following link: 3DS
NOTE: We could use the MyModel class also found in the same API and its "load(GLAutoDrawable, String)" and "render(GLAutoDrawable)" methods for loading and rendering objects with textures on them.
Alternatives?
Sure! You could use any of the classes found on the Internet for loading 3ds, obj or other format files.
A simple obj loader can be found at
Links:
3D GRAPHICS COMPLEX ISSUES (PART 1).
Billboards.
A billboard is a 2D texture which always faces the camera. Its main use is for particles, simulating forests (trees), distant mountains, etc.
Steps for orienting the billboard towards the camera.
The following code shows an example on how we can rotate the coordinates to always face the camera. You will also need the "TextureHandler" class (and its dependencies) to see it work:
If we want to use the camera and navigate through the billboards we need to do several other steps:
The following example shows all of the previous in detail:
Links:
Exercise.
NOTE: search for corresponding textures and 3DS objects on the Internet. (http://www.celestiamotherlode.net/ is a good place to look into)
NOTE: the Sun ray billboard should slice the sun into two equal semi-spheres.
|
323236
|
147
|
https://en.wikiversity.org/wiki?curid=323236
|
Computer networks -- 2007-2008 -- info.uvt.ro/Course 1
|
Quick links:
Bibliography.
Books.
In English:
In Romanian:
On-line material.
Please consult: Computer networks -- 2007-2008 -- info.uvt.ro#References.
|
323249
|
147
|
https://en.wikiversity.org/wiki?curid=323249
|
Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory 1
|
Quick links:
Agenda.
Please consult Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory agenda.
Evaluation.
Please consult Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory evaluation.
Communication / protocol definitions.
Links:
Communication / protocol design principles.
A communication protocol can be viewed as a set of conventions and standards that govern the connection and/or communication between two endpoints. In computer networks the protocol might offer features for:
Basically a protocol is a set of rules assuring that communication between one or more endpoints works properly.
Basic principles behind network protocol.
It is difficult to generalize about protocols because they vary so greatly in purpose and complexity. Most protocols address one or more of the following issues:
Links:
* it implies that the order in which the data is received, is the same one in which the data was sent;
* it is applicable in cases when there is a relation between transmitted data (when in order to process a piece of received data we also need all the data which was sent before that);
* it is mainly used with stream oriented protocols (for example and generally all the protocols based on it);
* it does not imply that the order in which data is received, is the same one in which it was sent;
* its main application is for those cases when there is no relation between transmitted data, or when the order is not important;
* it is mainly used with datagram oriented protocols (for example);
Communication / protocol types.
Ordered vs unordered.
Examples of ordered protocol usage:
Examples of unordered protocol usage:
Reliable vs unreliable.
Observations:
* it implies that all data sent is received with no loss;
* it is usually used in conjunction with connection oriented, stream oriented and ordered communication / protocols;
* it does not imply that all the data sent is received, thus parts of the sent data could be lost;
* it is usually used in conjunction with connection-less, datagram oriented and unordered communication / protocols;
Examples of reliable protocol usage:
Examples of unreliable protocol usage:
Links:
A connection-oriented communication or protocol implies that the entities involved in the process establish a common session (connection), and that all further data exchange is linked to this session.
It implies three phases:
* session (connection) establishment (opening) phase in which all entities agree to exchange data, (and usually establish an identifier for the resulting session);
* data exchange phase in which data is sent and received (usually tagged with the session identifier);
* session (connection) termination (closing) phase, in which no entity sends data, but ensures it has received all sent data, followed by destruction of the session;
Connection-oriented communication does not imply either data ordering or reliability, but in most connection-oriented protocols they are provided.
In contrast to the previous definition, a connection-less communication does not imply any relation between exchanged data, each exchange operation is treated individually.
Usually conection-less protocols are unordered and unreliable.
Connection-oriented vs connection-less.
Examples of connection-oriented protocols:
Examples of connection-less protocols:
Links:
Stream vs datagram oriented.
The main distinction between stream and datagram oriented protocols is the way they treat the exchanged data.
Assumes no data boundry, treating the exchanged information as a flow of octets obtained by concatenating the sent data.
This means that in order to exchange an amount of data, the sender could execute a different number of operations than the receiver.
Links:
Brief TCP/IP Introduction.
The Internet Protocol (IP) is the method or protocol by which data is sent from one computer to another on the Internet. Each computer (known as a host) on the Internet has at least one IP address that uniquely identifies it from all other computers on the Internet.
When you send or receive data (email, web page, etc), the message gets divided into little parts called packets. Each of these packets contains both the sender's and the receiver's Internet address.
IP is a connectionless protocol, which means that there is no continuing connection between the end points that are communicating. Each packet is treated independently without any relation with other packets.
There are several other protocols used together with (more exactly over) IP in order to provide additional features, the most common ones are:
Links:
IP Address.
An IP Address is an, unique address used in identifying hosts using the Internet Protocol.
To make it easier for us humans to remember, IP addresses are normally expressed in decimal format as a "dotted decimal number" like the one above.
Links:
Ports.
Both TCP and UDP use a special number present in the IP packet header to identify individual services, this number is named "port". The number of ports is restricted by the size of the corresponding field in the packet header (16 bits). Generally ports are mapped to specific programs that handle the corresponding requests.
Links:
DNS.
DNS (Domain Name System) is a system for converting host names and domain names into IP addresses on the Internet or on local networks that use the IP protocol. For example, when a Web site address is given to the DNS either by typing a URL in a browser or behind the scenes from one application to another, DNS servers return the IP address of the server associated with that name.
The DNS also stores other information such as the list of mail exchange servers that accept email for a given domain.
In providing a worldwide keyword-based redirection service, the Domain Name System is an essential component of contemporary Internet use.
Links:
Implementation issues.
Links
|
323251
|
147
|
https://en.wikiversity.org/wiki?curid=323251
|
Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory 3
|
Quick links:
Prerequisites.
The prerequisites necessary for this laboratory are:
Differences between TCP and UDP.
As we have seen in the first laboratory:
So we could conclude that these two protocols are diametrically opposite.
UDP sockets.
Like in the case of TCP sockets we usually split the applications in two main categories: servers and clients.
But in this situation we do not have UDP client and server sockets, we speak only of UDP sockets -- as UDP is a connection-less protocol. Nonetheless in order for the communication to take place the same conditions -- like in the case of TCP -- must be met:
Life-cycle.
Thus the generic life-cycle of an UDP socket would be:
As we can see there is nowhere any connection being made, and thus both the client and the server act the same way, the only distinction is that usually the client is the one that initiates the dialog.
Data exchange.
The data exchange step is split in two actions:
We could observe from the previous steps that the data exchange could be done with multiple entities, thus one client could speak with more than one server (or one server with multiple clients) by using the same socket -- something which in the case of TCP sockets is not possible.
Also we should observe that in the case of UDP sockets we must prepare in advance the buffer where we want to receive the data, and in the case buffer is to small to hold the entire received datagram, usually an error will be raised, and we can retry with a greater buffer.
"Connected" UDP sockets.
A second of the socket life-cycle is different in the fact that we introduce another step -- the connection step -- between the binding and the data exchange, and we remove the datagram remote socket address setup. This does not mean that we shall use a connection-oriented UDP socket. This is just an Java API facility which allows us to ignore the remote socket address when sending, provided that we communicate with only one server, thus no packet is sent during the connection step, and on the wire there is no difference between the two variants. So:
Java binary IO generic API.
The following API is used to handle binary data -- usually under the form of binary streams. Because there are a lot of methods available to the user, we shall list only the interface and class names.
Unicast vs. broadcast.
When sending messages we can distinguish three cases, based on the destination:
Observation: implicit and explicit refers to the fact that the sender must know the exact address of the involved destinations:
In case of broadcast we can use as the IP address:
Observation: if a host makes a broadcast, the sent packet is tagged with the its (the sender) IP address, and thus any receiving host can determine the source address.
Links:
Complete example.
In what follows we shall try to present a version of the example presented in the previous laboratory, but this time by using UDP sockets on both the client and server side: Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory 2#Complete example. (Also the way to run the client and the server is the same.)
Client.
The source code for both the client and the server can be found inside the Subversion repository in the folder examples/example-03.
Server.
As noted previously the source code for both the client and the server can be found inside the Subversion repository in the folder examples/example-03.
Assignment.
This is the second assignment, so please commit it to the folder "assignment-02".
Write a UDP client that:
Important: When sending the PING-PONG message, be careful to send it on the socket address from where the datagram came. See the method "getSocketAddress" from "DatagramPacket" class.
Example dialog.
client->broadcast PING
server->client PONG
client->server PING-PONG
Server Source.
This code can be foud under the folder "examples/example-04" inside the SVN repository.
|
323253
|
147
|
https://en.wikiversity.org/wiki?curid=323253
|
Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory 5
|
Quick links:
Prerequisites.
In order to successfully accomplish this laboratory, you should be familiar with:
Man pages.
Please consult .
ping.
This tool is used for checking that a specific host is reachable in an IP network, or for testing the local configuration.
PING works by sending ICMP ECHO_REQUEST datagrams to the target host and listening for ICMP ECHO_RESPONSE replies.
ECHO_REQUEST datagrams have an IP and ICMP header, followed by a struct timeval and then an arbitrary number of "pad" bytes used to fill out the packet.
PING provides estimates the round-trip time and records any packet loss, and prints a statistical summary when finished.
Usage.
The ping tool can be used for:
Drawbacks.
Although RFC 1122 prescribes that any host must accept an echo-request and issue an echo-reply in return, one finds that this standard is frequently not followed on the public Internet.
arping.
"arping" is similar in functionality with "ping", but operates by using the ARP protocol (opposed to ping which uses ICMP). Due to the usage of the ARP protocol the "arping" tool is only useful in the local network or in networks that provide an PROXY ARP.
|
323262
|
147
|
https://en.wikiversity.org/wiki?curid=323262
|
Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory evaluation
|
Quick links:
At the beginning of some laboratories you will receive an assignment, which should be completed -- individually -- during the two hours or until the end of next week -- depending on the assignment type (application or essay).
At the end of the assignment each student will upload the resulting source code or document on the SVN repository. For assignments which are applications, for those who are not present at the laboratory, or those who didn't manage to finish, have the possibility to upload the source code until the end of next week.
We shall do our best to provide the laboratory notes (including the assignment) a week in advance.
For each assignment a grade will be given from 0 to 10, following the following guidelines (for applications):
For essays the following rules apply:
The final grade for the laboratory is a weighted sum of the assignment grades, scaled from 0 to 10.
|
323263
|
147
|
https://en.wikiversity.org/wiki?curid=323263
|
Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory tools
|
Quick links:
Wireshark.
Please consult Computer networks -- 2007-2008 -- info.uvt.ro/Laboratory tools/Wireshark.
Java.
Please consult .
Eclipse.
Please consult .
Subversion.
Please consult .
|
323265
|
147
|
https://en.wikiversity.org/wiki?curid=323265
|
Computer networks -- 2007-2008 -- info.uvt.ro/Subversion repository
|
Quick links:
Redirection.
Please consult: Computer graphics -- 2007-2008 -- info.uvt.ro/Subversion repository, as the procedure is exactly the same, the only difference being the repository URL: svn://hephaistos.info.uvt.ro/info/2007-2008/computer-networks
|
323266
|
147
|
https://en.wikiversity.org/wiki?curid=323266
|
Computer networks -- 2008-2009 -- info.uvt.ro
|
Quick links: front; agenda; courses 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; examination.
About.
The current page (and hierarchical nested pages) are part of an introductory course held at Faculty of Mathematics and Informatics, part of the West University of , .
This page serves as a "front page" or "table of contents" for the entire work.
Audience.
The targeted audience in our faculty is second year students in the first cycle (conforming to the).
Agenda.
Having said that this course is of an introductory nature, and taking into consideration the nature of our faculty (that being more towards theoretical than engineering aspects) we shall try to provide:
For this the course is split into four (almost equally sized) parts:
For a more detailed view please consult the dedicated page.
Laboratories.
"To be written..."
Examination.
Please consult the dedicated page.
|
323282
|
147
|
https://en.wikiversity.org/wiki?curid=323282
|
Computer networks -- 2008-2009 -- info.uvt.ro/Examination
|
Quick links: front; agenda; courses 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13; examination.
Written exam.
Topics.
Please note that (for now) these are just a proposal and are bound to be modified.
Laboratory exam.
Attendances.
Minimum number of attendances: 11.
Topics.
Please note that (for now) these are just a proposal and are bound to be modified.
|
323290
|
147
|
https://en.wikiversity.org/wiki?curid=323290
|
Eesti.ee accessibility
|
=Overview of the website=
Eesti.ee is a one of a kind website. In their introduction it is described as following: "The State Portal eesti.ee provides safe Internet environment for communication with the state – offering reliable information and e-solutions for citizen, entrepreneur and official."
This sort of task defintily puts a lot of high expectations to one's functionality and security. One of the field of this high expectations would definetility be usability and accesibility.
As Eesti.ee is meant to be an online version of the State, catering its citizens needs in various fields (social support petitions, applying for several state-organized documents, - aids etc.), then one would expect this peticular site to cater those needs as the State is supposed to cater them in real life. This means multilanguage (aside estonian russian, english), support for disabled persons - as the "brick and mortar" facilities had to cater the needs of mobility impairment, then the internet removed the need for this type of support. But this research team fears, that with the absence of this major impairment to cater, the state has forgotten other - newly arisen impairment to serve. For example towards hearing and seeing impairment etc.
=Navigation (structure)=
The navigational principles of Eesti.ee are strictly mouse based. There are no apparent ways of keyboard-browseability. Although there is one noticeble feature, which many visually impaired (and others) will benefit from. There is a text magnifier input in the website, a content map and also the ability to browse the textual contents of the website (non-graphical version of the website).
=Content of the website=
Eesti.ee doesn't feature many modern multimedia solutions (flash, images), as the website's aim is not to so much entertain the user but rather to be a useful tool for one. As mentioned before, the content of the website is browseable by simply textual outtake (link to that is offered in the upper navigational bar), therefore one can say that the graphical interface is minimalistic.
What makes the usability more difficult (in terms of browseability and navigation), is the massive content provided by the website. As Eesti.ee is growing every month in terms of services offered to the user, the menubars consisting of functions have gotten quite massive. Although the management of the website has tried to simplify things by generating 3 main categories for functions, there is still too much information on the website for the user to comprehend.
=User inputs used=
There is a lot of Javascript and a multitude of anchors used in the site. This makes it hard for the possible visually impaired user to consume the content of the website.
=Screenshots of the website=
=Accessibility testing=
Overview of the automatic accessibility testing.
WAVE Toolbar is a Firefox toolbar which provides a mechanism for running WAVE reports directly within Firefox. The toolbar reports run entirely within your web browser.
The toolbar can check intranet, password-protected, dynamically generated, or sensitive web pages. Also, because the WAVE toolbar evaluates the rendered version of your page, locally displayed styles and dynamically-generated content from scripts or AJAX can be evaluated.
The WAVE toolbar features four types of reports: Errors, Features and Alerts, Structure/Order View, Text-only View, Outline View.
WAVE shows the original web page with embedded icons and indicators that reveal the accessibility information within the web page. Over 80 possible icons show missing alternative text for images, missing form labels, table structure, script elements and event handlers, document structure and reading order, and much more.
Developer's web page: http://wave.webaim.org
The Markup Validation Service by the World Wide Web Consortium (W3C) allows Internet users to check HTML documents for conformance to HTML or XHTML standards. It also provides a quick method for web page authors to check their posted pages for mark-up errors.
HTML validators operate by comparing the mark-up on a web page to the W3C standards. Once the validator has read the page and determined the applicable standards it looks for such things as missing opening or closing tags, missing quotation marks and other hand-coding errors.
The validator then provides a report indicating that the coding is correct or not. Errors are noted in a list. One error, such as neglecting to close a tag, can cause a cascade of errors through the page, producing dozens or even hundreds of noted errors. However when the page author addresses the first error listed it will also eliminate the "cascade errors".
This validator is also “An HTML validating system conforming to International Standard ISO/IEC 15445—HyperText Markup Language, and International Standard ISO 8879—Standard Generalized Markup Language (SGML)” – which basically means that in addition to W3C recommendations, it can validate according to these ISO standards.
Eesti.ee accessibility analysis (according to Section 508 and WCAG guidelines, automated testing).
Truwex Online (http://checkwebsite.erigami.com/accessibility.html), Web Accessibility Testing Tool (Section 508 compliance) was used to conduct the testing. The document that was elected for testing purposes was the front page of Eesti.ee (http://www.eesti.ee/est/), in Estonian language.
Let's look closer at the manually ordered report (by Section 508 and WCAG standards).
Accessibility testing results.
The parser found 8 accessibility issues. Some of them have to be checked manually.
Issues.
[508 (N)] [WCAG 12.4 (2)] Form control without explicit label is found.
Description. Form control should have non-empty explicit label, or at least non-empty title. Explicit label is a label tied with input by 'for'/'id' attributes.
[WCAG 2.2 (2)] Low-contrast text is found.
Description. Text color and its background color are too close: color difference should be no less than 400 and brightness difference should be no less than 125. Note: Contrast calculations here are based on colors specified via HTML markup. If colors you see by your eyes are in good contrast but Truwex says they are not, try to open your page in a browser with switched off images (set "Don't load images" option in FireFox or in Opera). It is possible that you use background images that make good contrast but without them the contrast is not good.
[WCAG 3.4 (2)] Fixed fonts are found.
Description. Use relative rather than absolute units in markup language attribute values and style sheet property values.
[WCAG 3.4 (2)] Fixed sizes are found.
Description. Fixed sizes other than font-size property are found. This includes absolute units of measure in frame sizes and in inline styles of HTML buttons and other text containers.
[WCAG 3.5, 12.3 (2)] Hardly reachable text for voice reader is found.
Description. Percent of text, reachable by voice reader within a specified time limit, is less than the defined threshold. I.e. our estimation shows that less than 75% of page's text is reachable in 90 sec (these are the default values). In other words, it may take a long time for a user with a screen reader software to reach certain parts of a web page. Consider using hierarchical headers H1, H2 etc. and skip links to create shortcuts for users of screen readers. Note: the Map shows only 10 the most hardly reachable text fragments.
[WCAG 6.4, 9.3 (2)] Device-dependent event handler is found.
Description. Elements with specified mouse event handlers should also have paired keyboard event handlers. E.g. 'OnClick' and 'OnKeyPress', 'OnMouseOver' and 'OnFocus' etc.
[WCAG 13.1 (2)] Link name/destination clash.
Description. Two links with the same text should go to the same page, otherwise their 'title' attributes should differ.
[WCAG-2 1.4 (2)] Low luminosity contrast text is found.
Description. Luminosity contrast ratio between text and background behind the text should be equal to or greater than 5:1, except if the text is pure decoration. Larger-scale text (at least 18 point or 14 point bold) can have a contrast ratio of 3:1. This is the WCAG 2.0 priority 2 (AA) requirement and it often gives the result different from WCAG 1.0 color contrast checks. Note: Contrast calculations here are based on colors specified via HTML markup. If colors you see by your eyes are in good contrast but Truwex says they are not, try to open your page in a browser with switched off images (set "Don't load images" option in FireFox or in Opera). It is possible that you use background images that make good contrast but without them the contrast is not good.
Warnings.
The parser found 20 accessibility warnings. Some of them have to be checked manually.
[508 (C)] [WCAG 2.1 (1)] The use of color must not be a single method for indicating important information on a web page.
Description. Manual check. Ensure that all information conveyed with color is also available without color, for example from context or markup.
[508 (D)] [WCAG 6.1 (1)] Documents must be organized so they are readable without requiring user agent support for style sheets.
Description. Manual check. Organize documents so they may be read without style sheets. For example, when an HTML document is rendered without associated style sheets, it must still be possible to read the document.
[508 (J)] Flicker rate must be in the specified limits.
Description. Manual check. Page shall be designed to avoid causing the screen to flicker with a frequency greater than 2 Hz and lower than 55 Hz. Check gif images and objects, applets, embed elements.
[508 (O)] [WCAG 13.6 (3)] Page without skip link.
Description. A 'skip link' is one of the methods in providing a mechanism for users of assistive technologies to skip repetitive navigational links. Keyboard users also fully take advantages of this method. E.g. assume a page with navigation links at its top, and the links are coded in HTML before the page's main content. And if before the navigation bar a 'jump to main content' link will be provided, it will be very simple for users to access page content, in browser using TAB key or in screen reader.
[508 (P)] Page requiring timed response must allow user to get more time.
Description. Manual check. When a timed response is required, the user shall be alerted and given sufficient time to indicate more time is required.
[WCAG 2.2 (2)] Images must have sufficient contrast.
Description. Manual check. Ensure that foreground and background color combinations on images provide sufficient contrast when viewed by someone having color deficits or when viewed on a black and white screen.
[WCAG 3.1 (2)] Use markup instead of images where possible (it should be looked over manually).
Description. Manual check. When an appropriate markup language exists, use markup rather than images to convey information. For example, use MathML to mark up mathematical equations, and style sheets to format text and control layout. Also, avoid using images to represent text -- use text and style sheets instead.
[WCAG 3.2 (2)] Document must be valid.
This document uses HTML 4.01 Transitional doctype. This document was successfully checked as HTML 4.01 Transitional! Passed, 2 warnings.
[WCAG 3.3, 3.5 (2)] Do not use headers and other structural markup only for visual effects.
Description. Manual check. Use header elements according to specification. Do not use them only for presentational effects, e.g., for bold text. Do not use BLOCKQUOTE element for indents only. Do not use emphasis elements such as EM and STRONG for font effects only.
[WCAG 3.6 (2)] Mark up lists.
Description. Manual check. Mark up lists and list items properly. If your page contains logical lists, mark up them with UL for unordered list, OL for ordered list, DL for definition list and LI for list item. Do not use tables with bullet images to imitate unordered lists. Do not use numbers in text for ordered lists: e.g., a line contains '1.1 Chapter' text and the next line contains '1.2 Next chapter' text.
[WCAG 3.7 (2)] Mark up quotations.
Description. Manual check. Mark up quotations with Q and BLOCKQUOTE elements.
[WCAG 4.1 (1)] Changes in the natural language must be clearly identified.
Description. Manual check. Clearly identify changes in the natural language of a document's text and any text equivalents (e.g., captions)
[WCAG 5.3 (2)] Do not use tables for layout if they can not be linearized properly.
Description. Manual check. Do not use tables for layout unless the table makes sense when linearized. Otherwise, if the table does not make sense, provide an alternative equivalent (which may be a linearized version).
[WCAG 6.2 (1)] Equivalents for dynamic content must be updated when the dynamic content changes.
Description. Manual check. Ensure that equivalents for dynamic content are updated when the dynamic content changes.
[WCAG 7.1 (1), 7.2, 7.3 (2)] Avoid flickering, blinking and movement in pages.
Description. Manual check. Until user agents allow users to control blinking, avoid causing content to blink (i.e., change presentation at a regular rate, such as turning on and off). Until user agents allow users to freeze moving content, avoid movement in pages. Check objects, applets and scripts.
[WCAG 8.1 (1)] Programmatic elements must be directly accessible.
Description. Manual check. Make programmatic elements such as scripts and applets directly accessible or compatible with assistive technologies [Priority 1 if functionality is important and not presented elsewhere, otherwise Priority 2.]
[WCAG 10.2 (2)] Implicit labels must be properly positioned.
Description. Manual check. For all form controls with implicitly associated labels, ensure that the label is properly positioned. The label must immediately precedes its control on the same line (allowing more than one control/label per line) or be in the line preceding the control (with only one label and one control per line).
[WCAG 11.1 (2)] Use the latest W3C technologies available whenever possible.
Description. Manual check. Use W3C technologies when they are available and appropriate for a task and use the latest versions when supported.
[WCAG 13.3, 13.4 (2)] Provide clear and consistent navigation.
Description. Manual check. Provide information about the general layout of a site (e.g., a site map or table of contents). In describing site layout, highlight and explain available accessibility features. Use navigation mechanisms in a consistent manner.
[WCAG 14.1 (1)] The clearest and simplest language must be used.
Description. Manual check. Use the clearest and simplest language appropriate for a site's content.
Tools used for examining the accessibility of the eesti.ee.
Technical assesment – in order to examine the technical accessibility solutions applied effectively we used
automated testing tool Truwex Online http://checkwebsite.erigami.com/accessibility.html
Involving Users in Evaluating Web accessibility – in order to explore usability issues that were not discovered by automated tools we:
a)examined pages by using graphical browers;
b)conducted a test by using specialized browser - Mac OS X VoiceOver accessibility feature
Overview of the real-time accessibility testing.
The recording of the accessibility testing session can be found here: http://www.youtube.com/watch?v=O12hJyg5rHc
The testing session was conducted using Mac OS X VoiceOver accessibility feature, Safari web browser and recorded using the Silverback application. VoiceOver allows a visually impaired user to move around the screen using the keyboard and the computer reads the titles of elements on screen as well as gives hints about what type of information the user can submit in different input fields.
The test assignment was to log in to the State Portal eesti.ee using Mobile-ID and send an email using the official @eesti.ee email address. The task was simplified as much as possible since from the very beginning it became apparent that the State Portal’s architecture makes it very difficult to navigate using a screen reader.
The testing session emphasized some of the major shortcomings in the way the State Portal is structured. First of all it is hard to find the Enter button to get to the login page since the HTML is poorly structured and does not correspond to the visual representation. Some of the input fields, such as the search box for example, are missing labels so there is no way for the screen reader to identify it as a search box.
For the user to get to the main content of the page he must first navigate through the left menu, which features dozens of items and sub-menus.
Overall the results of this simple accessibility testing session illustrate the shortcoming of the portal’s structure very nicely. This kind of testing is a great way for developers and designers to think of their products from a very different perspective then they normally would.
=Usability session=
Usability assessment strategy.
Our aim was that testing session per user should not last more than 40minutes. Users were asked to indicate when they are finished with a task or if they want to stop. Users give answers for all tasks in various ways - verbally or via questionnaire.
Session logic
Usability testing strategy.
The tasks which the subject has to complete are:
Note: users were not asked to complete the task but to find an appropriate link. Test session is conducted in full version,
Performance and satisfaction metrics.
1-Very easy;
2-Easy;
3-Pretty easy;
4-Neither;
5-Pretty difficult;
6-Difficult;
7-Very difficult;
Valid face to face and online usability assessment.
provided quick link "Services for citizens";
as this consists news, they find the homepage unuseful or not well organized;
find informatsion needed, therefore were in trouble or confused, only 10% scrolled down;
suggestion: better description could be - "Register your personal e-mail account";
Usability testing results.
Here are the main user requirements, which can be applied to various aspects of the State portal:
Here are the test results - http://spreadsheets0.google.com/ccc?key=tp3vWamJE8a2CbwenxnUVLw&hl=en - (it opens in Google Docs environment; notice the two tabs).
Overview of the hands-on usability testing.
In other to check for errors that automatic tools missed we conducted
a) manual test accoring to guidelines of WAI
b) involved a user in evaluating Web accessibility
A brief manual test
The goal was to examine the frontpage and it's accessibility. The structure of the test was based on the tasks
described on WAI guidelines.
1. Turn off images, and check whether appropriate alternative text for the images is available.
The search box disappears and is not accessible;
The icon "Sisene" (Enter) does not have alt text, but is accessible;
2. Turn off the sound, and check whether audio content is still available through text equivalents.
No audio content, therefore there was nothing to explore;
3. Use browser controls to vary font-size: verify that the font size changes on the screen accordingly and that the page is still usable at larger font sizes.
Font size changes accordingly;
4. Test with different screen resolutions, and/or by resizing the application window to less than maximum, to verify that horizontal scrolling is not required (caution: test with different browsers, or examine code for absolute sizing, to ensure that it is a content problem not a browser problem).
IE – 1280x1024 – no horizontal scrolling needed;
1024x768 - - no horizontal scrolling needed;
800x600 – horizontal scrolling needed;
5. Change the display color to gray scale (or print out page in gray scale or black and white) and observe whether the color contrast is adequate.
The boldest information areas are the tab „Ettevõtjale“ (Entrepreneur) and the line under it as well as the logo – as these sections are either on the top or in the center position of the page, they also stand out (together with the welcome text) from the rest of the information.
In general all information is readable.
6. Without using the mouse, use the keyboard to navigate through the links and form controls on a page for example, using the "Tab" key, making sure that all links and form controls are accessible and that links clearly indicate where they lead to.
Findings:
Structure of the tab movement: top navigation, left sidebar, middle part of the page, right column of the page, header.
Top navigation:
Search form – not possible to choose/change the radio buttons;
The recording of the usability testing session can be found here: http://www.youtube.com/watch?v=c6rgHOzTT7c
Recommendations for usability improvement.
Content.
=Conclusion=
The State portal eesti.ee is a complex website which needs to fulfil certain expectations. One of the main requirements is that the portal has to accommodate different needs of very different types of users.
One of the main shortcomings of the website is that it is not optimized for being used by people with disabilities and is clearly lacking in the accessibility department. There is a reason for that, since during the years the portal has been developing and growing very little attention has been put to the goal of making the portal complaint with accessibility standards. Another major problem of the portal is the structure of the HTML itself. The portal is table based and that makes it very hard to navigate for people with screen readers. There are lots of information and articles which are poorly structured and hard for users to understand.
Solving all of these problems requires a systematic approach. A new version of the portal is currently is the works and the project was started with conducting of a comprehensive usability and accessibility analysis. The redesign should transform the State portal to a product, which is easier and more pleasing to use.
|
323291
|
147
|
https://en.wikiversity.org/wiki?curid=323291
|
Elgg - Learning Network and Environment
|
See alsoWeb 2.0 tools
This is my reflection about Elgg tool
Purpose.
Traditional s (VLEs) are structured around courses, timetables and assessment. David Tosh, one of its creators has said "Elgg is all about a learner-centred, learner-controlled space in which you choose the connections, the resources and the communities you want to participate in".
Short description how Elgg can be used.
combines social software such as weblogs, wikis and other resources for education. This web application helps reshape e-learning into personal and social.
Relevant reading about Elgg
Personal versus social space.
Elgg gives learners a personal space (Personal Learning Environment - PLE) online to discuss, publish work in progress and link to and comment on relevant resources. Elgg also gives learners a social space (social networking space) to find and link up with other learners with similar interests to create a learning community.
Personal space versus e-portfolio for learning.
Elgg will serve as e-portfolio for learning to support learners’ reflection and knowledge construction. Elgg allows users to decide exactly who can view their content. Different levels of access can be set for individual blog entries, so some posts can be fully public and others only readable by a particular group or individual. You can read a about the differences between and e-portfolio in the course New Methods of Assessment.
Some Elgg networking spaces.
You are welcome to join "PLE & e-portfolio" group if you are interested in the concepts PLE and e-portfolio for learning. I encourage you to bring to the attention of peers web pages, articles, and other resources that are relevant to this topic.
|
323292
|
147
|
https://en.wikiversity.org/wiki?curid=323292
|
Ethics and Law in New Media/Marketing Advantages and Copyright Issues in Distribution of Music in YouTube
|
INTRODUCTION.
In February 2005 YouTube was launched as a beta version by three employees of PayPal, mostly for amateur videos. First YouTube video was posted by one of it’s creators, Yakov Lapitsky and it was shot at the San Diego Zoo. The distribution of original content was the next step following the success of the platform. In only a couple of months a Nike ad in which Ronaldinho was receiving his pair of Golden Boots hit first one million views on YouTube. Since then the success recipe that YouTube used is offering services both for companies and individual users.
In 2007, YouTube launched its Partner Program, adding advertising to most successful videos allowing users to six-figure incomes from the Web site. Especially since Google acquired YouTube the problem of copyright became more important than ever, since the Google wants profit. Anonymous user that are uploading videos with no copyrights aren't helping at all advertising. But YouTube started encouraging a creative ecosystem, convincing companies that it’s better for them to profit from the user generated content then to claim the copyrights and to remove it. And since this happened more and more brands chose to associate their names with stories of individuals that have huge audiences. So the model has shifted, but in the same time also the quality of UGC improved.
MAJOR RECORD COMPANIES.
Primary channel of Music consumption.
According to the IFPI Digital music report 2014 YouTube is the biggest single access point to music for consumers internationally, with one billion users worldwide. Following the fact, it can be stated that Youtube can provide the nowadays mainstream music a various set of comparable key performance indicators, such as total count, amount of subscribers, and sentiment.
Also, overall the direction of digital music distribution is following the trend stated above, as the industry now derives 27 per cent of its digital revenues from subscription and ad-supported streaming services, up from 14 per cent in 2011.
New age of synchronization of brands.
According to the Guardian , YouTube is the new TV for the young audiences, as the share of media consumers compared to the traditional tv (18-24 years old) is double the amount. For music business the synchronizing business, either by providing music into advertisement use or using product placement in the content produced has traditionally had a remarkable role . In addition to the game industry as a driving force of the genre, the YouTube channels’ social capital can be turned into a content marketing channel with a well-defined niche. A new generation of media actors, YouTube marketing agencies is currently growing fast, and though the current primary customers of theirs are the video loggers and individual artists, there is a huge value in the social capital the major labels channels as hubs of content have.
Cross-entertainment sector synergy.
One recent wave is to implement cross-entertainment sector collaboration in the marketing, also in the phase of initial content production. One successful example of this is Hunter Hayes: The YouTube orchestra. Warner Music Nashville/Atlantic Records in their need of launching a fresh country artist to young audiences came up with a idea for a mash-up: masking user generated content by contacting YouTube Superstars and creating a matching entity, where the original video is a hub of the user generated content videos, cross-directing traffic to both the superstars channels, and the channel of the record company where the new artists was launched.
Piracy.
"History".
One of the biggest challenges in the digitalization of music distribution is piracy, and from the last 20 years the great public remembers well at least the following law suits of copyright infringements in file sharing.: A&M Records vs. Napster (2001) and MGM Studios, Inc. vs. Kazaa Ltd. (2005).
Though the publicity gained from the warfare in court is said to be the most effective tool of marketing, they also are resource-intensive and financially highly risky processes for the record labels.
"YouTube vs. YouTube2mp3 - services".
In YouTube environment the biggest copyright threat are the 3rd party websites enabling people to download the music as mp3-versions and store the music on their computers, edit it and re-post it in their own name.
Due to the functional logic of the website, YouTube has taken the threat into consideration and is blocking technically the servers providing the services, as the functionality requires a contact to the API of YouTube. Though according to Google API’s terms of use “separating, isolating, or modifying audio or video components of any content is prohibited and could result in legal consequence”, Google has brought the fight further from the threat of lawsuit. As an example, in 2012 Google cracked down YouTube-MP3.org, stating that it’s 200 million users are not only going to be ignored but also criminalized .
"Major record labels: copyright world police?".
The next steps for fight against piracy have been developing the content id system (to be discover further later), and direct collaboration with the major record labels. In June Public Knowledge - web magazine wrote about Universal Music Groups and YouTube’s agreement that UMG could take down videos that did not infringe on UMG copyrights .
"Fair Use".
To elaborate more on the agreement, understanding the term “fair use” is required. According to Collins, the fair use in the US copyright law codified in section 107, Copyright Act 1976 can be identified in four factors: The first factor is to enquire into the nature and purpose of the offending work. If the work is for purposes such as commentary, criticism, education or news reporting, then the favor swings toward fair use. The second factor examines the nature of the copyrighted work and requires courts to consider whether it is published or unpublished, factual or fictional.
A fictional work is generally afforded a stronger copyright protection that one which is factual because of the creative investment. The third factor investigates how much of the original work was copied. This factor is addressed both quantitatively and qualitatively. The law will only tolerate copying to the point that is reasonable, but the substantiality differs between cases, and the fourth and final factor looks at the effect of the use upon the potential market for or value of the copyrighted work.
In other words the agreement between YouTube and UMG enables UMG to make decisions of cencorism in the YouTube realm regardless the power of court.
Future prospects: YouTube Music Key.
YouTube, until now an exclusively advertising-supported service, is planning what many see as a highly significant move into paid-for subscription. Plans for a premium service, which will offer a higher value experience to YouTube’s users, were announced in mid-2013 with launch expected in 2014. According to Time.com , the plan has been postponed and the closed six months beta has started November 17 2014. Taking a look at the existing market one might say that YouTube is terribly late. However, their strength is in the interlinked, variable content; not only they have the official music videos, but also myriad covers, parodies, remixes and original songs recorded by lesser known musicians. This enables them to provide a wide universe of variable content.
In the light of the current state of music business, the quality streaming services being really able to popularize the premium accounts are highly needed, as the concept of free streaming is according to Nielsen SoundScan already decreasing the digital music sales (the turn point was year 2013) . In other words, the upcoming YouTube Music Key - service may be the saviour of the music business, if its name fulfills the expectations.
INDEPENDENT ARTISTS and SMALL LABELS.
YouTube services for Independent Artists or how to earn money from copyrights.
In this context, artist in the beginning of their careers, creators of original content, have also higher standards to follow. It’s not enough anymore to take a guitar and play original content. This is how a middle category of artist, the ones who already had some success on internet and also less than 0 budget for promotion. Independent artists or indie have the feeling that are one step away from waking up in one morning with millions of views. Apparently YouTube likes this niche and adapted to the new trends, by offering a range of tools that could be used for a do it yourself marketing campaign. So the initial YouTube logo “Broadcast yourself” started also incorporating DIY.
"Partner Program".
YouTube Partner was released in 2007 and it was one of the first tools that would allow creators monetize their original content. Signing up for this service it’s quite easy and since YouTube takes care of ad placing, it seems to be an easy way to make money. On the other hand, the Partner Program will becomes more specialized since UGC is also following this trend.
"Music Key".
Services like Spotify, Deezer, [Beats Music] already had their business models developed on the base of monthly subscription for listening music and YouTube also wants to implement the idea. This is how Music Key was launched. This is probably one of the most controversial services launched by YouTube. In June 2014 they started changing the licensing terms and apparently the changes would have had a big impact over independent artists. The changes weren't clearly stated initially, but many artists received notifications. Rumors were around about the new streaming service that would oblige artists to make available all their songs on YouTube. So the release of one single video wasn't possible anymore without having listed on YouTube all songs. The creative community reacted and YouTube/Google dropped the plan in that moment. Conditions were re-negotiated and in November a new agreement was reached. This wouldn't have been possible without the contribution of [], [] and other agencies that protect independent music creator’s rights.
It is more than clear now that Google understood the meaning promoting content using communities and even created it’s own social media network Google+ This concept was
transferred to YouTube since users can create, follow and promote channels. The views for one video aren't as important anymore as channel subscriptions. It’s more about connecting the audience.
"YouTube Space; YouTube FanFinder".
One of the newest tools released in this category is YouTube Space, using the log line: “Bringing together the most creative people from the world”. Spaces have been designed as creative hubs in Los Angeles, London, Tokyo and New York. Google invested in production facilities, high technology, equipment for music and video production. It’s like an Abbey Road built for online community. People will normally suspect that there is something behind this new project. Not for now, since YouTube clearly states that: “Participating channels retain all their ownership of content, monetization, and creative control.” The conditions for using YouTube Space:
But for sure, newly released services like YouTube Fan Finders and YouTube Space seem to prepare the creative community for the launch of the new streaming service based on monthly payment.
Since the biggest provider of free online music and videos decided to go with this type of service, does this mean that the era of “free music” has come to an? It could be a clear statement regarding the monetization of creative works from the independent artists also, since it could be quite frustrating having millions of views on YouTube and no money in your account.
From marketing perspective..
It is not a pleasant moment in time for the small labels. As previously stated, YouTube made strategical business decision of making their service an unpleasant space for independent labels. Partly, offering “bad deals” to the small channel owners and in the same time “good deals” with the bigger players.
Google has set their ship into a new direction of creating their on music platform similar to Spotify. Hence, Spotify them self follow philosophy of disrespectful deal making. In other words a business communication based on “Take it or leave it”.
Unquestionably small labels generate enormous traffic on the platform. The licensing agency Merlin estimates 32.5% market share on the recorded music sales and streams. That is not surprising, due the fact that one of the main communication channels of indie artist is YouTube. Moreover, it is considered as a primary link to all other content distributed to other platforms. It generates most traffic from the music videos which make to some extent revenues.
For instance, labels such as Domino (Official label of the The Kills) posses around 200.000 subscribers which is a fairly good amount compared to big labels such as “Roca-a-fella” records with 700.000.
However, the point here is that Indie Labels are much dependent on YouTube due to its fast distribution nature. Moreover, it is still free to create and engage communities. Buying media coverage is expensive due the lack of resources: money and connections. That pictures a situation in which small labels are utilizing the Social Media channels as their primary marketing vehicle.
As seen above, the distribution of major record labels lies on different principles. Hence, man can consider that nowadays small labels will be slowly overtaken and put into a position where there is a no way of them to make reasonable marketing with the online streamers. The more money that has been put into “clicks” the more advertising revenue will generate for big players diluting the visibility of small players. YouTube acts more or less as a partner in the marketing campaigns of famous singers and very cold in the promotion of small but talented artists.
From copyright perspective..
Copyright protection is crucial no mater big or small record label. However, in the light of YouTube the rules of the game change. As previously stated copyright ownership violations could to lead to a paradoxical situations in which PR is considered more valuable than law penalties.
Essentially, all these labels want PR. Therefore spoofs and mash-ups generate more traffic. In other words “Work together than fight”.
When it comes down to copyright bigger players are much more sensitive. From the perspective of indie bands the copyright lies into only the 4 major elements.
Any additional legislation on YouTube are not taken into account. Most likely an indie band will tolerate any remixes or even cover versions of the songs as long they are in the scope of another emerging artist. Hence, that unspoken agreement could lead to big problems if a big labels hijacks a song and makes a hit out of it. Not the mention the revenue streams.
Regarding money issues, interesting and sometimes absurd situation happen in the music market. Since online streamers make additional and highly “customizable” contracts with artist, indie labels can end up with 1 million plays on Pandora and receive $ 16.89
Youtube is also willing to go on the path of Spotify and Pandora of paying major record labels in advance which is another sign that copyrights differentiate dramatically when it comes to big numbers.
Some small labels, even encourage fan community to remix and use their music and pay-as-mush as they want. However, this practice is not tolerated nor the YouTube and major record companies.
Essentially, the way small labels operate differentiate dramatically with the major record companies. As seen above, the stake of YouTube being the main communication channel is higher for small players. However, the indie artists do not have much chips in hand since online streamers and major labels have agreed to dictate the rules of the game. Small labels need publicity and YouTube is not paying them enough creating a cycle of decline. The less money you have, the less publicity you will have. It is not about talent anymore. And that is pity because major labels used to benefit highly from indie bands and vice-versa. Talent used to bring value. Nowadays not. As for YouTube, they are now in their best position of making the right moves.
As a platform that generates huge traffic (mostly coming from music videos) they can juxtapose and manage the agenda of marketing and copyright ownership.
This, no one put it so clearly as the vocalist of Radiohead who’s band made a huge pay-as-you-wish campaign:"Indie artists and labels are at the cutting edge of the future of music. To restrict them in this way is to risk creating an internet just for the superstars and big businesses."
USER GENERATED CONTENT - ETHICAL ASPECTS.
With changes that had happened recently in distributing in YouTube and in the Internet generally, the borders of the law are getting more and more blurry. YouTube trends like creating mashups, singing cover songs, using other`s music as own video background. Who actually has copyrights to what content? Is it ethical to use other people creation, change it a little and call it yours, even if law things everything is right?
Original content vs. remix.
Most YouTube users make videos to express them, it helps them to have a creative output. A lot of people who are shy, but want to be able to make something, are proud of have been known to make videos. However, most people do not make a profit from their videos, those who do are YouTube partners and get paid based on how many people view the videos and thus see the ads on and around the videos. The ads are what get the YouTube Partners money.
When you create something original, you own the copyright for it. Likewise, when people create content, they may have a copyright to it. As a creative community, it is essential that everyone on YouTube respect the copyrights of others. If you are not sure if someone will violate someone`s copyright, the safest thing to do is to create something completely original, with images and audio you have created. YouTube community guidelines make it very simple. If you created it, it is yours and this and only this, you can upload there. Reality is not that clear.
YouTube Talents.
YouTube is a good place for unknown singers to get noticed by big record companies. There are inspiring stories how people have become famous thanks to YouTube. Justin Bieber, a young Canadian singer, was discovered by his manager this way. Who introduced him with famous people in the music industry. He became famous overnight. It is an inspiring success story for people who seek this kind of fame and they try really hard to get there. Problem is, there are so many of them and how to get noticed in the middle of the crowd?
People need get their number of views, likes, comments and shares up, because these are the currency of YouTube. Perfect way to do it is to create a video of original content that goes viral. Easier say than do, so people think of other ways.
Users need to make them more easily noticeable in YouTube. So it becomes more about how you present your content, what mark words you use than just the content. Easiest way to do it is to use someone other`s fame to help you get noticed, to make you more easily find-able, because if users search some popular name, their content might pop up and some may even click on them. Is it right to use something what other people made to try to make yourself famous even if you are not making money by selling content created by others? If no, then how these people got famous who are on the top now? Are they forgetting how they got on the top, if they try to sue people for using their content to get themselves famous?
Maybe there is a chain of people who have used others fame to get somewhere with their career before started doing their own music? If this is true, then there might be a bunch of missing famous singers who had got on the top just because they broke some copyrights and ethics.
Clear ethical standards have not developed on how to attribute the video content moving through the synergistic sharing loop. Even though YouTube offers guidelines on how to attribute content, it’s clear that not everyone follows them, and certain scenarios fall outside those covered by the guidelines. Citizens are posting copyrighted material without permission. And the creator of some material cannot be identified.
Users download a song from YouTube, add there lyrics and upload the song again using the same famous name. Maybe the purpose of this activity is purely good will to help others to sing along for example. Some of them mention in video description that they do not have any right to this song, but still, they uploaded a content that does not belong to them. It is against the law. Even if they do not mean any harm, still they get views on their YouTube channel and it is possible to earn money from YouTube, if they have enough views. If money is earned then this activity is not ethical also anymore.
To use other people fame in their advantage, users can do many different things. One way to go is mash-ups. Users take music, created by others, short clips and combine their own music video of that. They have created nothing, only used what others have made, the end product might be nothing similar to whatever content has been used. Is it against the law or ethical?
Why to upload anything in YouTube, if it causes so many problems about what is ethical, what is not? Because all the eyeballs are there.
YouTube, a search engine?
If YouTube were a search engine, it would be after the Google search, the largest one. Second reason is that video in YouTube has a chance to go viral, it is less likely to happen if people would host their videos in their servers. Third reason is that YouTube is free.
Celebrities have taken notice that is nearly impossible to fight the mistakes people make against the law and the ways they use other people content. Only way to deal with it is to take an advantage of it. Good example to it is Beyonce`s new song called 7/11. It mimics the user created content as somebody recorded a video at home, using a simple one camera and not a large crew. Camera shakes sometimes, and footage is not edited much. No flashy effects and etc. She film herself dancing in the balcony, bedroom, bathroom sometimes sings along, but all-in-all, she mimics the fan created content. It is not hard to notice that it was the whole idea to make people do similar videos on their own to gain fame. And there are already some videos out that have the same name as her video has 7/11 and some of them are quite popular. There is no way that these videos would have such a large audience without the original song. This example proves that top singers try to turn piracy problem and ethical misbehavior into their advantage to advertise their own song.
In conclusion, the borders of the law are getting more and more blurry. Things that were against the law and unethical are now normal. Famous celebrities even try to encourage such behavior and turn it in their advantage.
NEW FRONTIERS - Space and copyrights.
Although independent artists are also affected by breaking the copyrights laws, there are still tips and advice on how to cross YouTube’s wide-reaching system known as “Content ID”. Probably one of the most interesting one is the case of Chris Hadfield, first Canadian Astronaut to walk in space. In 2013, he recorded himself singing David Bowie's "Space Oddity" in space, on the International Space Station (ISS). The public loved the song that reached over 24 million views. But YouTube had a big challenge trying to solve this case. Music and video were recorded in Destiny module, owned by America's space agency, NASA, but was transmitted through Canada, where a piano music was added. The problem is that no clear regulation of copyright in space exists. The video was taken off from YouTube in May 2014, but in November, due to an agreement with David Bowie, the video was available again on YouTube, but the “copyright in space” issue is still waiting for new challenges in order to be solved.
LOCAL MUSIC ROYALTIES TRADE BODY AFFECTIONS FOR MUSIC IN YOUTUBE.
Introduction.
Local music royalty trade bodies, in Estonian case - Eesti Autorite Ühing (EAU) / Estonian Authors' Society, that is responsible to collect royalties from playing the music in radios and elsewhere, are sometimes working against free music in YouTube.
Mass escape from YouTube.
In March 2009 a massive amount of YouTube music videos started to be pulled out from UK YouTube as Google and Performing Rights Society for Music (UK) did not reach to sufficient agreement .
Week later it reached to the first wave of deleting Estonian music videos from YouTube, among others music that producers had uploaded themselves. Estonian Authors' Society reported that all members of EAS have to report of their music BEFORE they upload their files to YouTube.
In the same time communication bureau Vare&Jaakola asked a rethorical question that how ethical it is that only licensed music is removed, but TV series, adds etc still remains. Moreover, search engines like Google also violates the rule for spreading personal information.
Search engine violations finally came as a topic 5 years later in May 2014, when European Court decided that everyone should have their privacy in internet and the ones who want could have rights to remove Google search engine links if they want so . Estonia became after Germany, France and UK the TOP fourth country that want to remove their content .
Conclusion.
So legal and ethical issues with music in YouTube are still in blurred area, as music is not the only area. Lot of TV series, adds etc should be in the same category, moreover if EAU or other organizations remove videos from YouTube automatically, but the video owner is not their member, then the owner should have rights to make a complain and ask for damages.
YouTube is still a valuable channel for big musical artist, latest example being Taylor Swift, who took off her music from Spotify and doubled the amounts of her songs YouTube views .
Artist want to earn money when their music is played. For example in radio. To do that they have to join trade body that collects the royalties. But in this case the trade body can also decide what happens with their music in YouTube (if artist does not inform that this is his/her channel - do not take it down).
"References".
|
323298
|
147
|
https://en.wikiversity.org/wiki?curid=323298
|
Functional programming -- 2008-2009 -- info.uvt.ro/Laboratory 2
|
References.
From the book Practical Common Lisp:
Creation
Inspection
Transformation
cons
List operations.
Exercises.
By using only <code>cons</code>, <code>nil</code> and atoms (numbers, symbols, etc.), write (and test) the expression that creates the following lists:
car, cdr
Considering that the variable <code>s1</code>, <code>s2</code>, etc. contain the following lists:
By using only <code>car</code> or <code>cdr</code> write the expression that returns the following:
cadr, ...
Now by using also <code>cadr</code>, <code>cdar</code>, and the other combinations, solve the same problem as above.
if
Control structures.
Reference:
Syntax:
Syntax example:
Basic example:
when
Reference:
Syntax:
Syntax example:
Basic example:
unless
Reference:
Syntax:
Syntax example:
cond
Reference:
Syntax:
Basic example:
let
Reference:
Syntax:
Syntax example:
Basic example:
defun
Defining functions.
Reference:
Syntax:
Syntax example:
Simple decisions
Exercises.
<code>less-than-or-equal-to</code>: Implement a function which takes two numeric arguments and determines if the first one is less or equal to the second (taken from Some Simple Programming Exercises):
<code>my-signum</code>: Implement a function that takes as arguments one number and returns:
Type predicates
<code>my-signum</code>: Update the previous function so that now it accepts any kind of argument, but if given anything else than a number it returns <code>nil</code>:
<code>is-a-list</code>: Implement a function that takes only one argument, and returns (taken from Some Simple Programming Exercises):
Lists
<code>compare-length</code>: Write a function that takes two lists as arguments and returns:
<code>compare-length</code>: Update the previous function so that it also accepts any kind of arguments, and in addition to the previous rules:
<code>only-third</code>: Write a function, using only <code>car</code> and <code>cdr</code>, which returns the third element of a list (taken from Some Simple Programming Exercises):
Data abstraction
<code>lookup-details</code>: Write a function which looks up information in a record. A record takes the following form of a list with three elements <code>(name age height)</code>. Your function should take two arguments (taken from Some Simple Programming Exercises):
<code>make-lookup-table</code>: Then write another function which, when given a record of the form given above, returns a lookup table as follows (you are not allowed to look inside the list, but instead you should use the previous defined function lookup-details) (taken from Some Simple Programming Exercises):
Recursion
(***) <code>prime-factors</code>: Write a function that takes a number and returns a list of its prime factors.
The current page is a simplified view of the page Laboratory 1, Laboratory 2 and Laboratory 4 from the previous years, which in turn is based on Laboratory 1, Laboratory 2 and Laboratory 4 by Cornel Izbasa;
|
323299
|
147
|
https://en.wikiversity.org/wiki?curid=323299
|
Functional programming -- 2008-2009 -- info.uvt.ro/Laboratory 3
|
References.
From the book Practical Common Lisp:
Observations
Examples.
The examples were not tested an they might contain small syntax errors, or (thought not likely) semantic errors.
These examples are implemented in a non tail recursive manner, and thus these are not adequate in real world applications (please see further laboratories for a proper (more efficient) implementation).
Arithmetic
<code>n!</code> (factorial):
Recursion over lists
<code>sum-lst</code> (shallow): adds all the numbers in a given list.
<code>sum-lst</code> (shallow): adds all the numbers in a given list, ignoring any other members (non-number).
<code>filter-numbers</code> (shallow): creates a new list that contains only the numbers of the original list.
<code>list-random</code>: creates a list of a given length, with random (integer) numbers from 0 up to a given limit.
<code>list-selection-sort</code>: given a list (of numbers) it sorts it ascending (it needs some auxiliary functions given below) (for details, please consult).
<code>list-remove</code>: deletes (only one) occurrence (if any) of a given element (maybe non-numeric) from a given list.
<code>list-minimum</code>: returns the minimum value of a (numeric) list.
<code>list-insertion-sort</code> (for details, please consult).
<code>list-insert</code>: given a (numeric) value it should insert it in an ordered (numeric) list, so that the resulting list is kept sorted.
Arithmetic
Exercises.
<code>compute-gcd</code>: computes the greatest common divisor of two numbers. (Hint: again a recursive function.)
<code>is-prime</code>: checks if the single argument given is a prime number or not. (Hint: this should be implemented as a recursive function.)
<code>prime-factors</code>: computes the list of a number prime factors.
Recursion over lists
<code>my-count</code> (shallow): compute the number of elements in a list (it's actually the list length) (taken from L-99: Ninety-Nine Lisp Problems -- P04).
<code>my-append</code>: implement a function that takes two lists and returns the concatenation of those two lists.
<code>my-reverse</code> (shallow): implement a function similar with <code>reverse</code> (taken from L-99: Ninety-Nine Lisp Problems -- P05).
<code>element-at</code> (shallow): Find the K'th element of a list (taken from L-99: Ninety-Nine Lisp Problems -- P03).
<code>replicate</code> (shallow): Replicate the elements of a list a given number of times (taken from L-99: Ninety-Nine Lisp Problems -- P15).
<code>drop-every-nth</code> (shallow): Drop every n'th element from a list (taken from L-99: Ninety-Nine Lisp Problems -- P16).
The current page is a simplified view of the page Laboratory 1 and Laboratory 2 from the previous years, which in turn is based on Laboratory 1 and Laboratory 2 by Cornel Izbasa;
|
323300
|
147
|
https://en.wikiversity.org/wiki?curid=323300
|
Functional programming -- 2008-2009 -- info.uvt.ro/Laboratory 4
|
References.
From the book Practical Common Lisp:
Observations
Examples.
The examples were not tested an they might contain small syntax errors, or (thought not likely) semantic errors.
Recursion over trees (nested lists)
<code>sum-tree</code> (deep): adds all the numbers in a given tree (a list containing other lists), taking into consideration even nested lists, ignoring any other members (non-number or non-list).
<code>sum-tree</code> (deep) (second solution).
<code>filter-numbers</code> (deep): the same as <code>filter-numbers</code>, but it should work on trees.
<code>filter-numbers</code> (deep): second solution, similar with sum-tree second solution.
Recursion over trees
Exercises.
<code>my-count</code> (deep): compute the number of elements in a tree.
<code>my-reverse</code> (deep): similar with the one above but it should work on trees.
<code>delete-all</code> (deep): Write a recursive function which takes an atom and a nested list as arguments, and returns a new list which is a copy of the old with all instances of the atom removed, using <code>cond</code> (taken from Some Simple Programming Exercises).
<code>my-flatten</code>: it takes a tree, and should create a list by "dissolving" the inner lists (taken from L-99: Ninety-Nine Lisp Problems -- P07).
More elaborate exercises
<code>compress</code>: If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed (taken from L-99: Ninety-Nine Lisp Problems -- P08).
<code>pack</code>: Pack consecutive duplicates of list elements into sublists (taken from L-99: Ninety-Nine Lisp Problems -- P09).
<code>pack-rle</code>: Use the result of the previous problem to implement the so-called run-length encoding data compression method. Consecutive duplicates of elements are encoded as lists <code>(n e)</code> where <code>n</code> is the number of duplicates of the element <code>e</code> (taken from L-99: Ninety-Nine Lisp Problems -- P10).
<code>pack-rle</code>: Modify the result of the previous problem in such a way that if an element has no duplicates it is simply copied into the result list. Only elements with duplicates are transferred as <code>(n e)</code> lists (taken from L-99: Ninety-Nine Lisp Problems -- P11).
<code>unpack-rle</code>: Given a run-length code list generated as specified in the previous problem, construct its uncompressed version. (taken from L-99: Ninety-Nine Lisp Problems -- P12).
|
323305
|
147
|
https://en.wikiversity.org/wiki?curid=323305
|
Functional programming -- 2009-2010 -- info.uvt.ro
|
About.
To be written...
Audience.
To be written...
Agenda.
As the "Functional programming" course is an introductory course, the purpose of the laboratory is to put in practice all (or at least the most important) theoretical concepts discussed during the lectures. Thus we are mainly concerned in:
All this should be achieved with the following setup: we could split ourselves (the students) into two (difficulty / interest) groups:
For further details (a more granular view) please also consult the dedicated page.
|
323307
|
147
|
https://en.wikiversity.org/wiki?curid=323307
|
Functional programming -- 2009-2010 -- info.uvt.ro/Laboratory/Agenda
|
Overview.
As the "Functional programming" course is an introductory course, the purpose of the laboratory is to put in practice all (or at least the most important) theoretical concepts discussed during the lectures. Therefore THE TOPICS DISCUSSED DURING THE LECTURES ARE MANDATORY AND FORM THE BASE OF OUR WORK. (Unfortunately I can't stress this fact enough...)
Getting back to the subject at hand we cover two major topics:
Before getting any deeper I propose to experiment with the following setup: we could split into two (difficulty / interest) groups:
Now that we've seen the two setups, here is a simple scenario of what a laboratory should be:
Medium -> advanced.
Laboratory 1 -- Introduction.
Go to contents.
Laboratory 2 -- Code abstraction.
Go to contents.
Laboratory 3 -- Data abstraction.
Go to contents.
Laboratory 4 -- Functional programming.
Go to contents.
Laboratory 8 -> 14 -- Projects.
Go to the dedicated page.
|
323308
|
147
|
https://en.wikiversity.org/wiki?curid=323308
|
Functional programming -- 2009-2010 -- info.uvt.ro/Laboratory/Notes 1
|
Discontinued due to lack of student interest.
Optional (but highly recommended) reading.
The following essays are stolen from Shriram Krishnamurthi:
Concepts
Languages
Quick preview
First contact with Lisp.
Interpreter.
Steps to get started with the Lisp interpreter:
Basic data types
Basic data-types.
Examples (the text <code>[1]></code> (for Common Lisp) or <code>«/code> (for Scheme) is actually the prompter and should not be written to the interpreter):
Generic topics
Basic code.
In the examples (for both Common Lisp or Scheme) notice that instead of putting the output of the evaluator on the next line, I've put the expected output as a comment after the expression <code>...expression... ; => ...expected-output...</code>; and I've also dropped the prompter <code>[1]></code>.
Arithmetic expressions
Boolean expressions
Type predicates
|
323313
|
147
|
https://en.wikiversity.org/wiki?curid=323313
|
Functional programming -- 2009-2010 -- info.uvt.ro/Laboratory/References
|
How to use these references?
There are multiple possible approaches, and the one that worked (and still works) for me:
From our faculty.
For the current laboratories there are also other materials available (from our faculty) (on-line):
People.
This link is a very good place to start.
|
323315
|
147
|
https://en.wikiversity.org/wiki?curid=323315
|
Functional programming -- 2009-2010 -- info.uvt.ro/Laboratory/Robots
|
To be finalized...
Dummy robot
Exercises.
The first exercise is to create your own robot control function. Again the steps are the following:
Moving the robot
Based on the previous example write a (recursive) function <code>move-robot-n!</code> that takes two arguments (the robot and a number) which moves the robot exactly n steps forward:
Finding the edge
Now make the robot move forward until it reaches the wall. (Check the API section to see how you could use either the <code>look-robot?</code>, <code>feel-robot?</code> or just <code>move-robot!</code> functions).
Going around the edge
Now make the robot do the following:
Fuzzy robot
Now make the robot do the following:
Narrow sighted robot
Based on the Fuzzy robot exercise, now make the robot do the following:
API.
Robot API.
All these functions should be used only inside the control function of the robot!
feel-robot?
smell-robot?
look-robot?
grab-robot!
turn-robot!
move-robot!
simulate-robot
create-world
create-robot
simulate-world
|
323317
|
147
|
https://en.wikiversity.org/wiki?curid=323317
|
Hybrid Narrative Ecosystem
|
or Course: Ecology of Narratives II
Teachers
Kai Pata - Tallinn University
Carina Roels - ITIN
/Participants/
Register yourself as a wiki user and add your name to the participant list!
= Course settings =
Tallinn University main Building Narva road 25, info from room P-511.
Skype: kaipata (for those who want to follow what we do in remote way)
Tools:
Joint Course Blog
Wikiversity for collaborative work (we do groupwork in Wikiversity pages)
Individual tools:
Brightkite.com or Zannel.com (additionally Twitter.com and Search.Twitter.com)
Flickr.com
Facebook.com
= Aims of the course =
= Brief outline =
A geotagging setting, conceivable as a hybrid narrative ecosystem will be developed with students, according to the principles of design based research, incorporating aspects of action research approach.
On 2 contact days:
After contact day, students work in groups to plan and augment a social narrative into the experimental setting.
Each students collects geolocative narrative data from the settings and reflects impressions. Collaboration will EMERGE.
After contact day the groups analyse data and prepare a report.
= Grading =
= Design experiment groups =
here will appear the group-work with design experiments
= Outline and resources =
DAY 1 27.04.
Theoretical introduction ecological thinking, enacted learning, embodied simulation forms.
Additional:
Introduction to design experiment.
Ecology of narratives as a design experiment
What? This theory is derived from ecological thinking, enacted learning, embodied simulation forms
Students start thinking what can be discovered and explored with this design experiment about cognitive interaction with stories.
How? This practice is derived from geolocative m-learning studies, Web 2.0 storytelling, emerging standards
Students start thinking, what is an applicable solution for urban hybrid narratives – who will participate, why, where, what tools are needed, how stories become visible for collaboration, which are new story-telling formats
Practical task Day 1: questions, topic of the narrative, personal tools.
Questions on slides
The presentation and testing and adjusting some possible tools and software.
Scenario 1
List of some possible Tools.
Perceptional level:
Elaborating stories and collaborating level:
Students start Wordpress accounts and become part of joint group blog contributors.
http://wordpress.com
Final narratives are elaborated in blog, using pictures from Flickr
To select certain stories, group stories, please always use several tags!
Practical task.
The design session is finalized and the groups prepare preliminary designs (1 h).
Slides with questions
Practical task goal in general: Students discuss the aspects presented in the slide and prepare in groups preliminary design – flow of narrative construction with tool, people, artifacts (landscape view and activity view) and tell a user story (can be audio-recorded during presentation). Their research questions. Data-collection methods. Monitoring strategy during design experiment.
The groups present their designs, the common ground is reached for applicable design..
Discussion: how the work continues for running the design experiment (monitoring and data-collection, how much narrative-writing and reflection is expected for the last contact day.)
27.04.09-5.05.09: Individual and collabrative work.
Geolocative activity in town.
Data collection of geolocative narratives, and emerging collaboration on stories.
Monitoring the storytelling
WHAT TO DO?
Work individually
Take pictures of the places, things, impressions that you visit or get
Upload with Brightkite or Zannel using locative function
Take only these pictures that trigger a story and remember why you took the picture
Monitor what other people upload
In their pictures or comments trigger you to do something, make more pictures
Record if some idea came from other people's pictures
Pictures are automatically transported to the Flickr an Facebook
Add your relevant tags + narrativeecology tag
You can browse and look what other people have uploaded
Look the map view as well
Comment pictures and texts if you feel so.
Add comments: why you took this picture
Blog about your pictures in joint blog. Pull the picture feed to illustrate your narrative.
You can blog of the other people pictures what give you a strong impression, use their pictures!
In the blog, use always selective tags (you decide which!) to extract certain stories
Monitor what other people do and comment if you think something interesting happened.
You must every day upload at least 3 pictures!
Students’ DAiLY reflect postings.
Writing impression in joint course blog, relating postings geolocatively with the artifacts from narrative
(data collection of cognition).
Monitoring what is going on.
Various feeds are pulled together to monitor the activity online
DAY 2 5.05.
Data analysis. Conclusions of the design experiment..
(we could use wiki)
|
323323
|
147
|
https://en.wikiversity.org/wiki?curid=323323
|
Information Management -- 2008-2009 -- info.uvt.ro
|
Course.
Optional Course 2nd Semester
Contents.
Part II. Application design..
For a specific activity like: supply chain, production , sales.
Labs.
Evaluation.
In the last three labs of the semester the designed projects will be presented.
The final mark will be given by the above considerations in the overall context of projects:
prof. dr. Alexandru Cicortas, [email protected]
|
323324
|
147
|
https://en.wikiversity.org/wiki?curid=323324
|
Information theory -- Computer Science-Mathematics connections -- info.uvt.ro
|
Entropy.
<math>0\log_2 0=0</math> convention.
"Connects with: Calculus"
In computing entropy, the convention that <math>0\log_2 0=0</math> convention is made due to the fact that <math>\lim_{x \to 0}x\log_2 x=0,</math> as a continuity argument.
Proof:
<math>\lim_{x \to 0}x\log_2 x = \lim_{x\to0}\frac{-\log_2\frac{1}{x}}{\frac{1}{x}}</math>.
may be applied, since <math>\lim_{x\to0}-\log_2\frac{1}{x}=-\infty</math> and <math>\lim_{x\to0}\frac{1}{x}=\infty</math>.
Thus, <math>\lim_{x\to0}\frac{-\log_{2}\frac{1}{x}}{\frac{1}{x}}=\lim_{x\to0}\frac{(-\log_2\frac{1}{x})'}{(\frac{1}{x})'}</math>
<math>=\lim_{x\to0}-\frac{1}{\ln2}\frac{(\ln\frac{1}{x})'}{(\frac{1}{x})'}</math>
<math>=\lim_{x\to0}-\frac{1}{\ln2}\frac{x(\frac{1}{x})'}{(\frac{1}{x})'}</math>
<math>=\lim_{x\to0}-\frac{1}{\ln 2}x=0.</math>
|
323326
|
147
|
https://en.wikiversity.org/wiki?curid=323326
|
International Year of Languages
|
The year 2008 was declared by the General Assembly of the United Nations as The . The coordination of the activities was given to the hands of UNESCO (official page). The year should adress activities on the language issues and multilingualism such as language education and investigation, language preservation, multilingualism and intercultural diversity promotion. This multilingual page links different pages touching the issue of language education, research in the field of languages and multilingualism within education.
Local coordination page.
"Not set."
|
323329
|
147
|
https://en.wikiversity.org/wiki?curid=323329
|
Lisp EN -- Laboratory 1 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Syntax.
3.14
20
1/3
55.2e-20
a
abc
1+
2pi
(1 2)
(1 (2 3) (4 (5 6)) 7)
"abc"
"123CDE"
("abc" 1 (33 "4"))
; this is a comment
(print 1) ; this in another comment
Arithmetic expressions.
Number types.
1
100
123456
1/2
2/3
1.0
20.33e01
3e-14
Arithmetic functions.
(+ 1 2 3 4) => 10
(- 1 2 3 4) => -8
(* 1 2 3 4) => 24
(/ 1 2 3 4) => 1/24
(mod 7 3) => 1
(rem 7 3) => 1
(1+ 2) => 3
(1- 2) => 1
(min 1 2 3) => 1
(max 1/2 2 33/5) => 33/5
(abs -2.3) => 2.3
(floor 1/2) => 1
(truncate 1/2) => 1
(ceiling 1/2) => 2
(round 1.5) => 2
(round 2.5) => 2
(sin (/ pi 2)) => 0.707106...
(signum -55) => -1
(signum -55/3) => -1
(signum -55.0) => -1.0
(sqrt 1/4) => 1/2
(exp 2) => 7.389056
(expt 5/3 2) => 25/9
(log (exp 2)) => 2
Boolean expression.
Predicates.
Objec type or identity predicates.
(atom 'a) => t
(atom "a") => t
(atom 1) => t
(atom nil) => t
(atom '(1 2)) => nil
(atom ) => ???
(listp ) => t
(listp '(1 2)) => t
(listp t) => nil
(listp nil) => ???
(symbolp t) => t
(symbolp nil) => t
(symbolp "a") => nil
(symbolp 'a) => t
(symbolp ) => ???
(null t) => nil
(null 'a) => nil
(null nil) => t
(null '(1 2 3)) => nil
(null ) => ???
Arithmetic predicates.
(minusp 1) => nil
(plusp 1) => t
(minusp 0) => nil
(plusp 0) => nil
(zerop 1) => nil
(< 1 2 3) => t
(< 1 3 1) => nil
(= 1 2 3) => nil
(/= 1 2 3) => t
(evenp 1) => nil
(oddp 1) => t
Boolean predicates.
(and t nil) => nil
(and t t) => t
(and 1 2 3) => 3
(and 1 nil) => nil
(or t nil) => t
(or nil nil) => nil
(or 1 2 nil) => 1
(or nil 1 nil) => 1
Equality predicates.
(eq 1 1) => t
(eq 1 1.0) => nil
(eq "a" "a") => nil
(eql 1 1.0) => nil
(eql '(1 2) '(1 2)) => nil
(eql "a" "a") => nil
(equal 1 1.0) => nil
(equal "a" "a") => t
(equal "a" "A") => nil
(equal '(1 2) '(1 2)) => t
(equalp 1 1.0) => t
(equalp "a" "A") => t
Lists.
Examples.
(1 2 3 4)
(a b c d)
(1 a b 2 c 3)
((1) (2) ())
Quoting.
(+ 1 2) => 3
'(+ 1 2) => (+ 1 2)
Functions.
(length ) => 0
(length nil) => ???
(length '(1 2 3)) => 3
(length '(1 (2 3 4 5) 6)) => 3
(car ) => nil
(car '(1 2)) => 1
(cdr ) => nil
(cdr '(1 2 3)) => (2 3)
(car (cdr '(1 2 3))) => 2
(cadr '(1 2 3)) => 2
(cddr '(1 2 3)) => (3)
(caddr '(1 2 3)) => 3
(sixth '(1 2 3 4 5 6 7)) => 6
(nth 3 '(1 2 3 4 5 6)) => 4
(nthcdr 3 '(1 2 3 4 5 6)) => (4 5 6)
(list 'a 'b 'c 'd) => (a b c d)
(list '(1 2) '(3 4)) => ((1 2) (3 4))
(append '(1 2) '(3 4)) => (1 2 3 4)
(append 1 2 3) => error!
(reverse '(1 2 3 4)) => (4 3 2 1)
(reverse '(1 (2 3) 4)) => (4 (2 3) 1)
(member 5 '(1 2 3)) => nil
(member 2 '(1 2 3)) => (2 3)
(member 2 '(1 (2 3) 4)) => nil
(subst 'a 1 '(1 2 1 3)) => (a 2 a 3)
(subst 'a 1 '(1 (2 1) 3)) => (a (2 a) 3)
User defined functions.
(defun "<function-name>" ("<argument-1>" ...) "<statement-1>" ...)
(defun my-sum (a b) (+ a b))
(my-sum 1 2) => 3
(defun my-evenp (n) (zerop (mod n 2)))
(my-evenp 2) => t
Assignment 1.
Until next Wednesday (2007-03-07) 24:00 you will have to send me by email the following assignment.
When you send the email please include in the subject "[LISP-EN-2] First_name Last_name" for the second year and "[LISP-EN-3] First_name Last_name" for the third year. Please paste the code inside the email, DO NOT ATTACH any files.
Write 10 user defined functions (by using defun), with a minimum of 2 parameters (one parameter is accepted but only as an exceptional case), which uses some of the library functions described in this lab. Please also include a short description for each one and 2 or 3 test cases with the results.
For example:
(defun pol2 (x a b c) (+ (* a x x) (* b x) c))
(pol2 1 2 3 4) => 9
(defun my-< (a b) (minusp (- a b)))
(my-< 1 2) => t
Ciprian Dorin Craciun
2007-03-01
[email protected]
|
323330
|
147
|
https://en.wikiversity.org/wiki?curid=323330
|
Lisp EN -- Laboratory 2 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Variables, parameters and constants.
Variables.
(defvar <name> [<initial-value> [documentation]])
(defvar var-1 1 "variable 1")
(print var-1) => 1
(defvar var-1 2)
(print var-1) => 1
Parameters.
(defparam <name> <initial-value> [documentation])
(defparameter param-1 1 "param-1")
(print param-1) => 1
(defparameter param-1 2)
(print param-1) => 2
Constants.
(defconstant <name> <initial-value> [documentation])
(defconstant const-1 1 "const-1")
(print const-1) => 1 and a warning
(defconstant const-1 2)
(print const-1) => 2
(constantp <symbol>)
(constantp 'var-1) => nil
(constantp 'param-1) => nil
(constantp 'const-1) => t
(constantp 1) => t
(constantp var-1) => ?
(constantp param-1) => ?
Assignment.
(setq <variable> <value>)
(setq <variable-1> <value-1> <variable-2> <value-2> ... <variable-n> <value-n>)
(setq a 1)
a => 1
(setq a 1 b 2)
a => 1
b => 2
(setq a b b a)
a => 2
b => 2
(psetq <variable-1> <value-1> <variable-2> <value-2> ... <variable-n> <value-n>)
(setq a 1 b 2)
(psetq a b b a)
a => 1
b => 2
(setf <place> <value>)
(setf <place-1> <value-1> <place-2> <value-2> ... <place-n> <value-n>)
(setq l '(1 2 3))
l => (1 2 3)
(setf (car l) 'a)
l => (a 2 3)
(setf (cdr l) '(5 6))
l => (a 5 6)
(setf (nth 1 l) 'b)
l => (a b 6)
(setq l '(1 2 3))
(setq (cdddr l) l) => infinite loop
Control statements.
Conditional forms.
(if <condition> <then-statement> [else-statement])
(if t 1 2) => 1
(if nil 1 2) => 2
(if t 1) => 1
(if nil 1) => nil
(when <condition> <statement-1> ... <statement-n>)
(when t (print 1) (print 2)) => 2 and 1, 2 is printed on the console.
(when t 1 2 3) => 3
(when nil 1 2 3) => nil
(unless <condition> <statement-1> ... <statement-n>)
(unless t 1 2 3) => nil
(unless nil 1 2 3) => 3
(cond
(<condition-1> <statement-1-1> ... <statement-1-n1>)
(<condition-2> <statement-2-1> ... <statement-2-n2>)
(<condition-m> <statement-m-1> ... <statement-m-nm>)
(t <statement-t-1> ... <statement-t-nt>))
(defun int-test (n)
(cond
((not (integerp n)) "non-integer")
((evenp n) "even")
((oddp n) "odd")
(t "error")))
(int-test 1) => "odd"
(int-test 2) => "even"
(int-test "a") => "non-integer"
Code style.
int-test
my-sum
*max-int*
*e*
(if short-cond short-then short-else)
(if cond
then
else)
(when short-cond short-result)
(unless short-cond short-result)
(when cond
statement-1
statement-2)
(unless cond
statement-1
statement-2)
(cond
(cond-1 result-1)
(cond-2 result-2))
Recursion.
Examples.
(defun my-expt (m n)
(cond ((zerop n) 1)
(t (* m (my-expt m (- n 1))))
(defun fibonacci (n)
(cond ((= n 0) 0)
((= n 1) 1)
(t (+ (fibonacci (- n 1))
(fibonacci (- n 2))))
(defun count-atoms (l)
(cond ((null l) 0)
((atom l) 1)
(t (+ (count-atoms (car l))
(count-atoms (cdr l)))
Assignment 2.
This assignment is due next Wednesday (2007-03-14) at 24:00, and should be sent by email.
When you send the email please include in the subject "[LISP-EN-2] First_name Last_name" for the second year and "[LISP-EN-3] First_name Last_name" for the third year. Please paste the code inside the email, DO NOT ATTACH any files.
Write 6 recursive functions:
The functions must be followed by 2 or 3 representative test cases.
These functions must be different than the ones presented in the lab.
Ciprian Dorin Craciun
2007-03-08
[email protected]
|
323331
|
147
|
https://en.wikiversity.org/wiki?curid=323331
|
Lisp EN -- Laboratory 3 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Classes of recursive calls.
Linear recursion.
A recursive function is a linear one if it calls it self only once per call.
(defun n! (n)
(cond
((<= n 1) 1)
(t (* n (n! (1- n))))
(n! 11) => 39916800
(defun remove-non-numbers (l)
(cond
((null l) nil)
((numberp (car l))
(cons (car l) (remove-non-numbers (cdr l))))
(t
(remove-non-numbers (cdr l)))
(remove-non-numbers '(1 2 a b 3 4)) => (1 2 3 4)
Fat (exponential) recursion.
A recursive function has a "fat" behavior if it calls it self two or more times per call.
(defun fibonacci (n)
(cond
((= n 1) 0)
((= n 2) 1)
(t (+ (fibonacci (- n 1)) (fibonacci (- n 2))))
(fibonacci 1) => 0
(fibonacci 2) => 1
(fibonacci 3) => 1
(fibonacci 4) => 2
(fibonacci 10) => 34
(fibonacci 20) => 4181
(defun ackermann (m n)
(cond
((zerop m) (1+ n))
((and (plusp m) (zerop n))
(ackermann (1- m) 1))
(t
(ackermann (1- m) (ackermann m (1- n))))
(ackermann 3 4) => 125
Tail recursion.
A tail recursive function is just a linear recursive function in which the last executed operation is the recursive call.
In general most linear recursive functions, and some exponential recursive functions, can be rewritten as tail recursive functions by adding additional "accumulator" arguments. The new function is an auxiliary function which will be called by a wrapping function with the default values for the accumulator arguments.
(defun n!-a (n a)
(cond
((zerop n) a)
(t (n!-a (1- n) (* a n)))
(defun n! (n)
(n!-a n 1))
(n! 5) => 120
(n! 10) => 3628800
(defun fibonacci-a (n a1 a2)
(cond
((<= n 1) a1)
(t (fibonacci-a (1- n) a2 (+ a1 a2)))
(defun fibonacci (n)
(fibonacci-a n 0 1))
(fibonacci 1) => 0
(fibonacci 2) => 1
(fibonacci 3) => 2
(fibonacci 4) => 3
(fibonacci 10) => 34
(fibonacci 100) => 218922995834555169026
(defun my-reverse-a (l r)
(cond
((null l) r)
(t (my-reverse-a (cdr l) (cons (car l) r)))
(defun my-reverse (l)
(my-reverse-a l nil))
(my-reverse '(1 2 3 4)) => (4 3 2 1)
(defun my-clone-a (l r)
(cond
((null l) r)
(t (my-clone-a (cdr l) (append r (list (car l)))))
(defun my-clone (l)
(my-clone-a l nil))
(my-clone '(1 2 3 4 5))
Shallow and deep recursion.
These concepts apply to list (or different data-structure) processing functions.
A shallow function is a function which takes into account only the given list, ignoring any contained lists.
(defun count-atoms-shallow (l)
(cond
((null l) 0)
((atom (car l))
(1+ (count-atoms-shallow (cdr l))))
(t
(count-atoms-shallow (cdr l)))
(count-atoms-shallow '(1 2 (3 4 5) 6 7)) => 4
A deep function is a function which operates on the given list, and all the contained lists.
(defun count-atoms-deep (l)
(cond
((null l) 0)
((atom (car l))
(1+ (count-atoms-deep (cdr l))))
(t
(count-atoms-deep (car l))
(count-atoms-deep (cdr l))))
(count-atoms-deep '(1 2 (3 4 5) 6 7)) => 7
Recursive functions.
Tail and shallow recursive functions.
Rewrite the standard functions:
(my-reverse-shallow '(1 2 3 ((4)) (5 6 7) 8 9)) => (9 8 (5 6 7) ((4)) 3 2 1)
(my-remove-shallow 1 '(1 2 3 (1 2 3 4 (1)))) => (2 3 (1 2 3 4 (1)))
Write the following functions:
(unique '(1 2 3 1 2 3 4 5 5 5 6)) => (1 2 3 4 5 6)
(my-min-shallow '(1 2 3 4 5)) => 1
(defun my-min-shallow-a (l m)
(cond
((null l) m)
((< (car l) m)
(my-min-shallow-a (cdr l) (car l)))
(t
(my-min-shallow-a (cdr l) m))
(defun my-min-shallow (l)
(my-min-shallow-a (cdr l) (car l)))
(my-min-shallow '(1 2 3 4 5)) => 1
(my-min-shallow '(2 1 3 4)) => 1
(my-min-shallow '(4 5 3 1)) => 1
(my-list-equal '(1 2 3) '(1 2 3)) => t
(prime-p 2) => t
(prime-p 4) => nil
(div-sum 6) => 2 + 3 => 5
(defun div-sum-a (n d s)
(cond
((= d n) s)
((zerop (mod n d))
(div-sum-a n (1+ d) (+ s d)))
(t
(div-sum-a n (1+ d) s))
(defun div-sum (n)
(div-sum-a n 2 0))
(div-sum 6) => 5
(div-sum 10) => 7
(div-sum 1000) => 1339
(digit-sum 12345) => 15
Deep functions.
(my-reverse-deep '(1 2 3 ((4)) (5 6 7) 8 9)) => (9 8 (7 6 5) ((4)) 3 2 1)
(my-remove-deep 1 '(1 2 3 (1 2 3 4 (1)))) => (2 3 (2 3 4 ))
(my-min-deep '(10 2 (1) 5 6)) => 1
(defun my-min-deep-a (l m)
(cond
((null l) m)
((listp (car l))
(min (my-min-deep-a (car l) m) (my-min-deep-a (cdr l) m)))
(t
(my-min-deep-a (cdr l) (min (car l) m)))
(defun my-min-deep (l)
(my-min-deep-a l most-positive-fixnum))
(my-min-deep '(2 3 4 (1 2 3 (0)))) => 0
(my-min-deep nil) => most-positive-fixnum
(my-list-equal-deep '(1 (2) 3) '(1 (2) 3)) => t
(flatten '(1 2 (3 4 5 (6) 7) 8)) => (1 2 3 4 5 6 7 8)
(defun flatten (l)
(cond
((null l) nil)
((listp (car l))
(append (flatten (car l)) (flatten (cdr l))))
(t
(cons (car l) (flatten (cdr l))))
(flatten '((1 2 3) 4 (5 (6 (7 8 9))))) => (1 2 3 4 5 6 7 8 9)
Assignment 3.
For the next week you don't have a home assignment.
But instead you will sustain a short test at the beginning of the next week lab. The problems will be about recursive functions:
For examples please consult the previous list.
Ciprian Dorin Craciun
2007-03-15
[email protected]
|
323332
|
147
|
https://en.wikiversity.org/wiki?curid=323332
|
Lisp EN -- Laboratory 4 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Input / output.
print.
It is used to output at the console the representation of its argument.
If used directly in the interpreter we could see the value printed twice:
(print <value>) => <value>
(print 1) => 1
(print '(1 2 3 4)) => (1 2 3 4)
(print "abc") => "abc"
read.
It is used to read and parse the data from the console.
It takes no arguments and reads exactly one object.
By one object we understand a number, string, symbol, list, etc. In a word whatever can be written to the interpretor can be read with this function.
(read) => <parsed-read-value>
Returning multiple values.
values.
There are cases when we want to return multiple values from a function.
To obtain this we use the function values which takes any number of arguments and returns a special structure which holds all the given values.
(values <value-1> ... <value-n>) => <value1>; ...; <value-n>
(values 1 2 3) => 1; 2; 3
(defun prod-div (a b)
(values (* a b) (/ a b)))
(prod-div 1 2) => 2; 1/2
(prod-div 100 5) => 500; 20
Functions returning multiple values.
(floor 1.5) => 1; 0.5
(round 1.5) => 2; -0.5
multiple-value-bind.
If we are using a function which return multiple values (through values) we must use multiple-value-bind form to bind each value to a set of variables.
If we use that function without using multiple-value-bind, only the first value is considered, the rest being ignored.
(multiple-value-bind (<name-1> ... <name-n>)
<function-call-returning-multiple-values>
<statement-1>
<statement-n>)
=> <statement-n>
(multiple-value-bind (a b)
(floor 1.5)
(list a b)) => (1 0.5)
Grouping forms.
progn, prog1 and prog2.
progn is used to group multiple statements together. The value returned by this form is the value returned by the last statement.
(progn
<statement-1>
<statement-n>)
=> <statement-n>
(progn
(setq a 1)
(setq b 2)
(+ a b))
=> 3
prog1 and prog2 are similar with progn except that the value returned by each one is the value returned by the first, respectively the second statement.
(prog1
<statement-1>
<statement-n>)
=> <statement-1>
(prog2
<statement-1>
<statement-2>
<statement-n>)
=> <statement-2>
(prog1 1 2 3 4) => 1
(prog2 1 2 3 4) => 2
(progn 1 2 3 4) => 4
let and let*.
let and let* are used to create a lexical scope in which the given variables are bound to the given initial values.
The value returned by both forms is the value returned by the last statement.
The difference between let and let* is how they execute the "initial-value" expressions. let executes them in "parallel", and let* executes them "sequencialy".
(let
((<variable-1> <initial-value-1>)
(<variable-n> <initial-value-n>))
<statement-1>
<statement-n>)
=> <statement-n>
(let*
((<variable-1> <initial-value-1>)
(<variable-n> <initial-value-n>))
<statement-1>
<statement-n>)
=> <statement-n>
(setq a "a-is-1")
(setq b "b-is-2")
(print a) => "a-is-1"
(print b) => "b-is-2"
(let
((a b))
(print a) => "b-is-2"
(print b)) => "b-is-2"
(print a) => "a-is-1"
(setq a "a-is-1")
(setq b "b-is-2")
(let
((a b)
(b a))
(print a) => "b-is-2"
(print b)) => "a-is-1"
(let*
((a b)
(b a))
(print a) => "b-is-2"
(print b)) => "b-is-2"
Iterative forms.
dolist.
dolist is used to iterate a list (at the first level).
The value returned by the form is the value of the "return-value" expression. This is optional, and in case it is not given it returns nil.
(dolist (<variable> <list> [return-value])
<statement-1>
<statement-n>)
=> <return-value> or nil
The following examples shows how we can print the contents of a list:
(defun print-list (l)
(dolist (e l)
(print e)))
(print-list '(1 2 3 4))
If we want to sum the values in a list we can do:
(defun sum-list (l)
(let ((sum 0))
(dolist (e l sum)
(setq sum (+ sum e)))))
(sum-list '(1 2 3 4)) => 10
dotimes.
dotimes is used to iterate over a sequence starting with 0 until a given upper bound with a step of 1.
Like in the case of dolist the value returned is given by the "return-value" expression, or if missing nil.
(dotimes (<variable> <upper-bound> [return-value])
<statement-1>
<statement-n>)
=> <return-value> or nil
(dotimes (i 5) (print i)) => 0 1 2 3 4
(dotimes (i 5.1) (print i)) => 0 1 2 3 4 5
Implementing the factorial function with dotimes would be:
(defun n! (n)
(let ((f 1))
(dotimes (i n f)
(setq f (* f (1+ i))))))
(n! 4) => 24
(n! 50) => 30414093201713378043612608166064768844377641568960512000000000000
do and do*.
do and do* are the most complex iterative forms.
Just like let and let*, the difference between do and do* is that do evaluates the "initial-value" and "next-value" expressions in "parallel", meanwhile do* executes them sequentially.
(do
((<variable-1> <initial-value-1> <next-value-1>)
(<variable-n> <initial-value-n> <next-value-n>))
(<termination-condition> <return-value>)
<statement-1>
<statement-n>)
Fibonacci function could be written with do as:
(defun fibonacci (n)
(do
((i 1 (1+ i))
(a1 0 a2)
(a2 1 (+ a1 a2)))
((= i n) a1)
(print i)
)
(fibonacci 1) => 0
(fibonacci 2) => 1
(fibonacci 3) => 1
(fibonacci 10) => 34
(fibonacci 100) => 218922995834555169026
"Surgical" functions.
rplaca and rplacd.
rplaca and rplacd are used to modify the car, respectively cdr of a pair. (A pair is the result of cons.)
The value returned by these functions is the given pair.
These functions can be used to build circular lists.
(rplaca <pair> <new-car-value>) => <pair>
(rplacd <pair> <new-cdr-value>) => <pair>
(setq c (cons 1 2))
(print c) => 1 . 2
(rplaca c 3)
(print c) => 3 . 2
(rplacd c 4)
(print c) => 3 . 4
(setq l '(1 2 3))
(rplaca (car l) l) => ?
(rplacd (cdr l) l) => ?
(rplacd (cddr l) l) => ?
Other "surgical" functions.
The following functions are used just like their counterparts, except that they modify the given list instead of creating a new one.
(setq l '(1 2 3 4 5))
(print (reverse l)) => (5 4 3 2 1)
(print l) => (1 2 3 4 5)
(print (nreverse l)) => (5 4 3 2 1)
(print l) => (5 4 3 2 1)
Assignment 4.
This assignment is due next Wednesday (2007-03-28) at 24:00, and should be sent by email.
When you send the email please include in the subject "[LISP-EN-2] First_name Last_name" for the second year and "[LISP-EN-3] First_name Last_name" for the third year. Please paste the code inside the email, DO NOT ATTACH any files.
Write 6 functions:
The functions must be followed by 2 or 3 representative test cases.
The functions must be different than the ones presented at the laboratory.
Ciprian Dorin Craciun
2007-03-22
[email protected]
|
323333
|
147
|
https://en.wikiversity.org/wiki?curid=323333
|
Lisp EN -- Laboratory 5 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Evaluation functions.
eval.
As we know Lisp treats code and data the same. The code is nothing more than a data structure which has a well specified form (the form is the syntax). The interpretor receives a data structure and tries to execute it step by step.
The same functionality is available to the user through the function eval.
(eval <statement>) => <evaluation>
(eval '(+ 1 2)) => 3
(do
((in (read) (read)))
((cond
((eq in 'q) t)
(t (prin1 (eval in)) (princ #\nl) nil)
) nil))
(defun read-eval-print
(princ "» ")
(prin1 (eval (read)))
(princ #\nl)
(read-eval-print))
(read-eval-print)
funcall.
funcall is used to programatically evaluate a function. It is usually used when we know in advance the number of arguments for the given function.
(funcall <function> <argument-1> ... <argument-n>) => <evaluation>
(funcall #'+ 1 2 3)
(funcall #'print "abc")
apply.
apply, like funcall is used to evaluate a function, but it is used when we don't know in advance the number of arguments for the given function.
(apply <function> <argument-list>) => <evaluation>
(apply #'+ '(1 2 3 4 5)) => 15
(apply #'cons '(a b)) => (a . b)
(defun max-list (l)
(apply #'max l))
(max-list '(1 2 3 5 4 3 2 1)) => 5
(defun sum-list (l)
(apply #'+ l))
(sum-list '(1 2 3 4 5)) => 15
mapcar function family.
Many times we want to apply a specific function to all the elements in a given list, and for this reason mapcar function family was built.
mapcar takes as arguments a function and a set of lists. The result is obtained by applying the given function to parameters obtained from each list. For example:
(mapcar #'+ '(1 2 3) '(5 6 7)) => (6 8 10)
(mapcar <function> <list-1> ... <list-n>)
{<function> applied on arguments: second element in <list-1>, ..., second element in <list-n>)
(mapcar #'oddp '(1 2 3 4 5)) => (t nil t nil t)
(mapcar #'cons '(1 2 3 4 5) '(a b c d e)) => ((1 . a) (2 . b) (3 . c) (4 . d) (5 . e))
maplist has the same syntax, but instead of using as arguments to the given function the n-th element of the lists, it uses the remaining n-th pairs in the list.
(maplist #'length '(a b c d e)) => (5 4 3 2 1)
(maplist #'cdr '(a b c d e)) => ((b c d e) (c d e) (d e) (e) )
Lambda.
lambda is a form used to define "anonymous" functions. It has the same syntax as defun, except that lambda doesn't name the function but returns it.
(lambda (<argument-1> ... <argument-n> <statement-1> ... <statement-n>) => <statement-n's value when executed>
(mapcar (lambda (x) (- 0 x)) '(1 2 3 4 5))
Conditional list processing functions.
(count-if #'oddp '(1 2 3 4 5 6 7)) => 4
(count-if #'atom '(1 2 3 (4 5 6) 7 8)) => 5
(remove-if #'oddp '(1 2 3 4 5 6 7)) => (2 4 6)
(apply #'max (remove-if-not #'numberp '(1 2 a b c (100 200) 3 4 d e f))) => 4
(find-if #'minusp '(1 2 3 4 5 6)) => nil
(find-if #'plusp '(1 2 0 2 1)) => 1
(substitute-if 0 #'oddp '(1 2 4 1 3 4 5)) => (0 2 4 0 0 4 0)
assoc function family.
(assoc <key> <record-list>) => <record>
(assoc-if <key> <record-list>) => <record>
(rassoc <key> <record-list>) => <record>
(rassoc-if <key> <record-list>) => <record>
(setq db '((1 . a) (2 . b) (3 . c)))
(assoc 1 db) => (1 . a)
(assoc 0 db) => nil
(assoc-if #'evenp db) => (2 . b)
(assoc-if #'oddp db) => (1 . b)
(rassoc 'a db) => (1 . a)
(rassoc 'z db) => nil
Assignment 5.
This assignment is due next Wednesday (2007-04-04) at 24:00, and should be sent by email.
When you send the email please include in the subject "[LISP-EN-2] First_name Last_name" for the second year and "[LISP-EN-3] First_name Last_name" for the third year. Please paste the code inside the email, DO NOT ATTACH any files.
The assignment for next week is:
You will have to provide examples for all the implemented functions and to use lambda as the argument function. For example:
(defun my-count-if (l) ...)
(my-count-if (lambda (e) (numberp e)) '(1 2 3 4 a b c)) => 4
Ciprian Dorin Craciun
2007-03-28
[email protected]
|
323334
|
147
|
https://en.wikiversity.org/wiki?curid=323334
|
Lisp EN -- Laboratory 6 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Macros.
macroexpand and macroexpand-1.
The two functions are used to see the macro-expansion of a given code. The difference between the two is that macroexpand expands as many times as there is a macro in the resulting code, meanwhile macroexpand-1 expands the code only once, thus allowing us to see the behavior step-by-step.
(macroexpand <code_>) ;=> <expanded-code>
(macroexpand-1 <code_>) ;=> <expanded-code>
(macroexpand '(and a b c)) ;=> (if (not a) nil (if (not b) nil c))
(macroexpand '(or a b c)) ;=> (if a a (if b b c))
(macroexpand '(cond (a a) (b b))) ;=> (if a a (if b b nil))
(macroexpand '(cond (1 1) (2 2))) ;=> 1
(macroexpand-1 '(and a b c)) ;=> (cond ((not a) nil) ((not b) nil) (t c))
(macroexpand-1 '(or a b c)) ;=> (cond (a) (b) (t c))
(macroexpand-1 '(cond (a a) (b b))) ;=> (if a a (if b b nil))
(macroexpand-1 '(cond (1 1) (2 2))) ;=> 1
Difference between "'", "`", ",", and ",@".
(setq a 1 b 2 c 3)
'(a b c) ;=> (a b c)
`(a b c) ;=> (a b c)
`(a ,b c) ;=> (a 2 c)
`(a (,b c)) ;=> (a (2 c))
`(a ',(+ a b c)) ;=> (a '6)
(setq l '(a b c))
'(1 l) ;=> (1 l)
`(1 l) ;=> (1 l)
`(1 ,l) ;=> (1 (a b c))
`(1 ,@l) ;=> (1 a b c)
(setq l '(1 2 3))
`(+ ,@l) ;=> (+ 1 2 3)
(eval `(+ ,@l)) ;=> 6
defmacro.
defmacro is used -- as it's name suggests -- to define a macro. In Lisp a macro is nothing else than a normal function which is called when the code is parsed (at compile-time, not at run-time).
(defmacro <name> (<argument-1> ... <argument-n>)
<generating-statements>)
(defmacro variabila (nume valoare)
(list 'setq nume valoare))
(defmacro variabila (nume valoare)
`(setq ,nume ,valoare))
(macroexpand '(var a 1)) => (setq a 1)
gensym.
Wrong:
(defmacro my-dotimes (n &rest statements)
`(do ((x 0 (+ x 1)))
((>= x ,n))
,@statements))
Right:
(defmacro my-dotimes (n &rest statements)
(let ((g (gensym)) (h (gensym)))
`(do ((,h ,n)
(,g 0 (+ ,g 1)))
((>= ,g ,h))
,@statements)))
Assignment 6.
This assignment is due next Wednesday (2007-04-18) at 24:00, and should be sent by email.
When you send the email please include in the subject "[LISP-EN-2] First_name Last_name" for the second year and "[LISP-EN-3] First_name Last_name" for the third year. Please paste the code inside the email, DO NOT ATTACH any files.
The assignment for next week is to implement 6 complex (not simple) macros, (also use gensym), and then for each 3 examples on how the macro will expand for a given set of arguments (you can use macroexpand-1).
Ciprian Dorin Craciun
2007-04-13
[email protected]
|
323335
|
147
|
https://en.wikiversity.org/wiki?curid=323335
|
Lisp EN -- Laboratory 7 -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Property lists.
The get function is used to access (and with the use of setf to modify) the property list of a symbol. In CLisp each symbol has an associated property list.
This list can be compared with a key-value mapping that exists for each symbol. The set of property lists can also be compared with the contents of a relational database table in which the symbol is the primary key, the property is a column, and the value is the tuple's value for the given column.
(get <symbol> <property>) => <value>
(setf (get <symbol> <property>) <value>)
In the following example we try to build a parent-child database.
(defmacro father (p c)
`(setf (get ,c 'father) ,p))
(defmacro mother (p c)
`(setf (get ,c 'mother) ,p))
(defmacro father? (c)
`(get ,c 'father))
(defmacro mother? (c)
`(get ,c 'mother))
(father 'a 'c)
(mother 'b 'c)
(father 'c 'e)
(mother 'd 'e)
(father 'f 'd)
(mother 'g 'd)
(father? 'c) ;=> a
(mother? 'c) ;=> b
(mother? (father? 'e)) ;=> b
Advanced usage of lambda.
When we call lambda it creates a lexical closure, and holds a reference to all the symbols that were available in the context (and at the time) it was called.
(defun make* (n)
(lambda (x) (* x n)))
(setf *2 (make* 2))
(setf *3 (make* 3))
(mapcar *2 '(1 2 3 4)) ;=> (2 4 6 8)
(mapcar *3 '(1 2 3 4)) ;=> (3 6 9 12)
(mapcar (make* 5) '(1 2 3 4)) ;=> (5 10 15 20)
Ciprian Dorin Craciun
2007-04-19
[email protected]
|
323336
|
147
|
https://en.wikiversity.org/wiki?curid=323336
|
Lisp EN -- Test -- 2006-2007 -- info.uvt.ro
|
Lisp EN -- 2006-2007 -- info.uvt.ro
Contents.
The test will be next Saturday (2007-04-21), maybe in the morning. (The exact hour and location I will transmit at the next lab.)
The test will consist of 4 problems, each requesting to implement a specific function from the categories presented below. The time frame (the time allocated to solving the problems) will be 1 hour.
(Shallow) Tail recursive functions.
This class of functions was presented in:
Examples:
(my-remove-shallow 1 '(1 2 3 4 3 2 1)) => (2 3 4 3 2)
(my-remove-shallow 'a '(a b c a (a b c) a b)) => (b c (a b c) b)
(my-count-if #'oddp '(1 2 3 4 5)) => 3
Deep recursive functions.
This class of functions was presented in:
Examples:
(my-substitute-deep 'a 1 '(a b c (a b c) a b c)) => (1 b c (1 b c) 1 b c)
(my-find-if-deep #'zerop '(1 2 3 (0 4) 1 2)) => t
(my-find-if-deep #'numberp '(a b c (d e f) g)) => nil
Iterative functions.
These functions should be implemented by using one of the following:
Examples:
(my-sum '(1 2 a b c (3 4)) => 3
Macros.
You will have to implement a macro that has a similar functionality to a given one. See Lisp EN -- Laboratory 6 -- 2006-2007 -- info.uvt.ro.
Examples:
(my-repeat 5
(print "This message")
(print "should appear 5 times..."))
Evaluation.
Each of the four problems will be evaluated on a scale from 0 to 10.
For example some evaluation guide lines:
Ciprian Dorin Craciun
2007-04-15
[email protected]
|
323337
|
147
|
https://en.wikiversity.org/wiki?curid=323337
|
Narrative ecologies
|
The course: Ecology of Narratives (Note: Course number in Tallinn University IFI7106)
Kai Pata
/Participants/
Register yourself as a wiki user and add your name to the participant list!
Introduction.
Ecology of narratives course offers an opportunity to participate in hybrid environment in the real time metadesign experiment which uses the cultures of participation approach for design for accumulating the geolocative narrative datasets and for analyzing how such datasets may be used.
The course is based on the ideas of designing the narrative ecosystem through communities of users, exploring its functioning by participation, and analyzing the system using the accumulated data from the course participants.
Ways of application of such design ideas are tourism, marketing, history, social participation, learning etc.
At previous years we have constructed a hybrid ecosystem by bottom up approach, using Brightkite.com, Flickr.com, Twitter.com, Facebook.com and Wordpress.com (or other blog). In this system datafeeds (tagfeeds, friendfeeds) can be mashed, monitored, and data can be aggregated using different methods. This allows the participants to monitor in realtime the narrative ecosystem, perceive and analyze swarming phenomena etc.. Swarming phenomena are discussed from the point of view of marketing ideas, brands, places.
Two full contact days are planned in the beginning and end of the course to design the experiment and analyze the results. In this part of the course students work in groups and in a wiki page they will compose the ideas what they expect from experiment, and what they experienced technically and emotionally, and how the results could be used. Remote participation will be possible (we try to broadcast all lectures).
Second activity in his course is individual. Each participant is supposed to contribute weekly into the narrative activity (images, tweets, texts). The topics and the areas from where to upload are not determined. Students' workload is to upload every day something (some photos, tweets using Brightkite, Twitter and Flickr) and to do at least one summarizing post in the corse Facebook page to reflect their experiences in this system.
Participation in the experiment is encouraged at any location of the World. New participants may be involved into the experiment.
Part of the grade will be:
a) participation in group-work and writing this evaluation and
b) individual reflections and uploading pictures/tweets.
= Course settings =
Tallinn University main Building Narva road 25 and remote places, such as:
Course Facebook and interconnected social software and geographical places (see figure).
For group-work we will use Wikiversity pages
= Aims of the course =
= Brief outline =
Lecture part: Introduction to the narrative ecology and its application possibilities. The meta-design framework for cultures of participation.
Groupwork: Planning the meta-design experiment (ideas how to use swarming and self-organization for example for marketing and branding with narratives, deciding necessary aspects of data-collection that will answer the needs of this experiment, interconnecting personal tool-settings). After 1st contact day, students work individually and augment a social narrative into their chosen settings in hybrid ecosystem.
Lecture part: Introduction of the data analysis methods, including soft ontology methods.
Groupwork: Evaluation of the experiment in hybrid ecosystem. The groups will select and discuss the data collected in the meta-design to answer their research questions. After 2nd contact day the groups analyse data and prepare a report.
= Grading =
= Design experiment groups =
Here will appear the group-work with design experiments
= Outline and resources =
DAY 1.
Theoretical introduction.
1. What is narrative ecology? Hybrid ecosystem concept. Positioning narratives in hybrid ecosystem. Enaction and embodied simulation.
2. Swarming as storytelling in hybrid ecosystem. Swarm marketing for ideas, brands, places and stories. Example cases.
GIS and affordances of places
3. The meta-design framework for developing narrative swarming. The principles of meta-design for cultures of participation.
4. How can we initiate swarming in hybrid ecosystem. Combining the tools, planning the interactions.
Introduction to design experiment.
5. Forming teams for meta-design. For understanding hybrid ecosystem, it must be tested in action in a meta-design experiment.
The teams will discuss:
1) How? This practice is derived from geolocative m-learning studies, Web 2.0 storytelling, emerging standards
Students start thinking, what is an applicable solution for urban hybrid narratives – who will participate, why, where, what tools are needed, how stories become visible for collaboration, which are new story-telling formats
a) Which new ideas for swarm marketing can be generated for hybrid ecosystems?
b) Which locations and information channels within and across software in hybrid ecosystem will initiate swarming?
2) What? This theory is derived from ecological thinking, enacted learning, embodied simulation forms
Students start thinking what can be discovered and explored with this design experiment about cognitive interaction with stories.
What possibilities there will be to collect data for answering the following research questions:
a) Which narrative triggers (themes) in hybrid narrative ecosystem will initiate swarming?
b) Which swarming phenomena can be recognized?
c) How do participants perceive swarming phenomena in narrative ecosystem?
Seminar outline:
List of Tools.
compatible with yahoo_id (flickr), twitter, brightkite
http://www.openstreetmap.org/
The groups present their design ideas in wiki.
Discussion: how the work continues for running the design experiment (monitoring and data-collection, how much narrative-writing and reflection is expected for the last contact day.)
Individual and collabrative work.
Monitoring what is going on.
Personal sites are connected together (links, mashes etc.) to monitor the activity online
Participants will monitor the storytelling.
Narrative activity in hybrid ecosystem.
Data collection as personal narratives and swarming type of activities on stories.
Students’ weekly reflect postings.
Writing weekly impression in course Facebook page, e.g. relating postings geolocatively with the artifacts from their personal narratives
(data collection of cognition).
DAY 2.
Data analysis.
Conclusions of the design experiment. (we will use group wiki)
|
323340
|
147
|
https://en.wikiversity.org/wiki?curid=323340
|
Operating Systems 2 EN -- Assignment -- 2006-2007 -- info.uvt.ro
|
Operating Systems 2 EN -- 2006-2007 -- info.uvt.ro
Description.
The assignment is to write an article about operating systems aspects (architectural design, implementation, etc.). It should be about 4-5 A4 pages written with 12pt or 14pt and no more than 1.5 line spacing. The article will be presented during the lab, for about 10-20 minutes. (Based on a schedule I will announce in the coming weeks.)
Please inform me what subjects have you chosen by mail [email protected] until 2007-03-20.
The article deadline is until 7th week.
|
323342
|
147
|
https://en.wikiversity.org/wiki?curid=323342
|
Operating Systems 2 EN -- Laboratory 5 -- 2006-2007 -- info.uvt.ro
|
Operating Systems 2 EN -- 2006-2007 -- info.uvt.ro
Memory mapped file.
Links.
Memory Mapped Files
System call.
#include <sys/mman.h>
void * mmap (
void * address,
size_t size,
int protection,
int flags,
int file_descriptor,
off_t file_offset);
int munmap (
void * address,
size_t size);
Example.
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
void terminate (char * message)
printf ("[EE] %s\n", message);
exit (1);
void terminate_if (int condition, char * message)
if (condition)
terminate (message);
int main (int argc, char * * args)
char * file_name;
int file_descriptor;
void * file_address;
size_t file_size;
struct stat file_stat;
int outcome;
int page_size;
int page_count;
int page_index;
char * page;
terminate_if (argc != 2, "Invalid number of arguments");
file_name = args[1];
file_descriptor = open (file_name, O_RDONLY);
terminate_if (file_descriptor == -1, "Can not open the file.");
outcome = fstat (file_descriptor, &file_stat);
terminate_if (outcome == -1, "Can not stat the file.");
file_size = file_stat.st_size;
file_address = mmap (0, file_size, PROT_READ, MAP_PRIVATE, file_descriptor, 0);
terminate_if (file_address == MAP_FAILED, "Can not map the file.");
page_size = 16;
page_count = file_size / page_size;
for (page_index = 0; page_index < page_count; page_index++) {
page = ((char *) file_address) + (page_index * page_size);
int i;
printf ("%8x |", page_index * page_size);
for (i = 0; i < page_size; i++)
printf (" %02x", (unsigned char) page[i]);
printf (" | |");
for (i = 0; i < page_size; i++)
printf ("%c", ((page[i] >= 32) && (page[i] < 127) ? page[i] : ' '));
printf ("|\n");
outcome = munmap (file_address, file_size);
terminate_if (outcome != 0, "Can not unmap the file.");
outcome = close (file_descriptor);
terminate_if (outcome != 0, "Can not close the file.");
Non blocking streams.
When using non blocking operations, a read or write operation immediately returns when there is no data to be read / written.
For more information consult the man pages for:
Example.
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
void terminate (char * message)
printf ("[EE] %s\n", message);
exit (1);
void terminate_if (int condition, char * message)
if (condition)
terminate (message);
int main (int argc, char * * args)
char * file_name;
int file_descriptor;
struct stat file_stat;
int loop;
int outcome;
char buffer[1024];
terminate_if (argc != 2, "Invalid number of arguments");
file_name = args[1];
file_descriptor = open (file_name, O_RDONLY | O_NONBLOCK);
terminate_if (file_descriptor == -1, "Can not open the file.");
loop = 1;
while (loop) {
printf ("[II] Reading...\n");
outcome = read (file_descriptor, buffer, sizeof (buffer));
if (outcome > 0) {
int i;
printf ("[»] ");
for (i = 0; i < outcome; i++)
printf ("%c", buffer[i]);
printf ("\n");
} else {
if ((outcome == 0) || (errno == EAGAIN)) {
printf ("[II] Sleeping...\n");
sleep (1);
} else
terminate ("Can not read from file.");
outcome = close (file_descriptor);
terminate_if (outcome != 0, "Can not close the file.");
|
323348
|
147
|
https://en.wikiversity.org/wiki?curid=323348
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory 1
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
Agenda.
Please consult Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory agenda.
Evaluation.
Please consult Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory evaluation.
Tools.
Please consult Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory tools.
|
323349
|
147
|
https://en.wikiversity.org/wiki?curid=323349
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory 2
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
Võro system paths.
/home/ciprian/test.sh
/tmp
./test.sh
a/b/c
../a/b/c
test.sh
~/abc
Zulu bash commands.
POP PLAYER commands.
<command> [<argument>] ...
echo Hello world!
echo 'Hello world!'
man bash
whoami
List of commands.
<command> [argument] ... { <; | && | ||> <command> [argument] ... } ...
echo hello ; echo world
date ; sleep 2 ; date
Comments.
echo a # b c
Basic bash script.
nano ./test.sh
#!/bin/bash
echo hello world
exit 0
chmod +x ./test.sh
./test.sh
File system commands.
Current directory.
pwd
cd
cd <directory>
pwd
cd /tmp
pwd
cd
pwd
Viewing.
cat.
cat [flag] ... [files] ...
cat ./test.sh
cat -n ./test.sh
stat and file.
stat <file> ...
file <file> ...
stat /etc
stat /etc/group
file /etc/group
file /bin/bash
less and more.
less [file]
more [file]
less /etc/services
more /etc/services
cat /etc/services | less
Directory creation.
mkdir [flag] ... <directory>
stat ./dir1
mkdir ./dir1
stat ./dir1
mkdir ./dir2/dir3
mkdir -p ./dir2/dir3
Directory deletion.
rmdir [flag] ... <directory>
stat ./dir1
rmdir ./dir1
stat ./dir1
rmdir ./dir2/dir3
rmdir -p ./dir2/dir3
File creation.
touch <file>
stat ./file1
touch ./file1
stat ./file1
touch ./file1
stat ./file1
File deletion.
rm [flag] ... <file> ...
stat ./file1
rm ./file1
stat ./file1
mkdir dir4
touch dir4/file4
rm dir4
rm dir4/file4 dir4
mkdir dir5
touch dir5/file5
rm -R dir5
Copying.
cp [flag] ... <sourc> <target>
cp /etc/group .
stat ./group
cp /etc/passwd ./passwd-copyied
stat ./passwd-copyied
mkdir ./dir6
cp ./group ./dir6
stat ./dir6/group
cp ./dir6 ./dir7
cp -R ./dir6 ./dir7
stat ./dir7/group
cat ./group
cp /etc/passwd ./group
cat ./group
Moving.
mv [flag] ... <sourc> <target>
stat ./dir6
stat ./dir7
mv ./dir6 ./dir7
mv ./dir6 ./dir8
stat ./dir8/group
cat ./passwd-copyied
cp /etc/group ./group
cat ./group
mv ./passwd-copyed ./group
cat ./group
Querying.
ls.
ls [flag] ... <directory>
ls /tmp
ls ~
ls -a ~
ls -l ~
ls -a -l ~
ls -al ~
ls /etc
ls -1 /etc
find.
find <directory> [test] ... [action] ...
find /etc
find /etc -type d
find /etc -type f
find /etc -name 'g*'
|
323350
|
147
|
https://en.wikiversity.org/wiki?curid=323350
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory 3
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
Variables.
Assignment.
a=abc123
b='abc 123'
a = abc123
unset a
unset b
Substitution.
echo a b c
echo $a $b $c
echo z$az z$bz z$cz
echo z${a}z z${b}z z${c}z
echo "$a" "$b" "$c"
echo "${a}" "${b}" "${c}"
echo '$a' '$b' '$c'
echo '${a}' '${b}' '${c}'
Default defined (internal) variables.
echo "${SHELL}"
echo "${UID}"
echo "${PWD}"
echo "${HOME}"
echo "${EDITOR}"
echo "${PAGER}"
echo "${HOSTNAME}"
set
Environment variables.
export EDITOR=mcedit
export PATH="${PATH}:~/bin"
export
Positional variables.
nano ./test.sh
#!/bin/bash
echo '${0}='"${0}"
echo '${#}='"${#}"
echo '${1}='"${1}"
echo '${2}='"${2}"
echo '${*}='"${*}"
echo '${@}='"${@}"
chmod +x ./test.sh
./test.sh
./test.sh a
./test.sh a b
./test.sh a b c
./test.sh a b c d
./test.sh 'a b c' d e
Pipes and redirections.
<command> [argument] ... > <output-file>
<command> [argument] ... < <input-file>
<command> [argument] ... < <input-file> > <output-file>
<command-1> [argument] ... { | <command-2> [argument] ... } ...
find >./listing.txt
sort <./listing.txt
sort <./listing.txt >./sorted-listing.txt
find | sort >./sorted-listing.txt
ls | sort
Basic filter commands.
wc.
wc [flag] ... [file] ...
wc /etc/group
ls /etc | wc -l
cat and tac.
cat [file] ...
tac [file] ...
cat /etc/passwd /etc/group
tac /etc/group
head and tail.
head [flag] ... [file]
tail [flag] ... [file]
head /etc/group
head -n 2 /etc/group
ls | tail -n 2
sort.
sort [flag] ... [file] ...
sort /etc/passwd
grep.
grep <flag> ... <pattern> [file]
grep root /etc/passwd
find / | grep bash
find / | grep -E -e '\.sh$'
tr.
tr [flag] ... <set-1> [set-2]
nano ./text.txt
tr -s ' ' <./text.txt >./text-tr.txt
cat ./text-tr.txt
nano ./text.txt
tr 0-9 a-j <./text.txt >./text-tr.txt
sed.
sed [flag] ... { -e <operator> } ... [file] ...
[address]p
[address]d
[address]s/[pattern-1]/[pattern-2]/
[address]y/[pattern-1]/[pattern-2]/
<line-number>
/<pattern>/
<address>,+<count>
sed '/root/d' </etc/group
sed -e 's/root/ADIMN/g' </etc/group
sed -n -r -e '/^a/p' </etc/group
sed -n -e '1,10p' </etc/group
sed -n -e '1,+9p' </etc/group
Exercises.
stat ./test.sh
./safe-delete.sh ./test.sh
stat ./test.sh
stat /tmp/recycle/test.sh
./pattern-find.sh /etc bash
nano ./text.txt
./underscore.sh ./text.txt
cat ./text.txt
nano ./text.txt
./uppercase.sh ./text.txt
cat ./text.txt
nano ./text.txt
./words.sh ./text.txt
nano ./text.txt
./rot13.sh <./text.txt >./text-enc.txt
cat ./text-enc.txt
|
323351
|
147
|
https://en.wikiversity.org/wiki?curid=323351
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory 4
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
Exit status.
true
echo "${?}"
cat /etc/passwd
echo "${?}"
false
echo "${?}"
cat /tmp/non-existing-file
echo "${?}"
exit <status>
Command chaining.
<command> [argument] ... { && <command> [argument] ... } ...
<command> [argument] ... { || <command> [argument] ... } ...
true && echo 'command succeeded.'
false && echo 'command succeeded.'
test -f /etc/passwd && echo 'file exists.'
true || echo 'command failed!'
false || echo 'command failed!'
test -f /tmp/non-existing-file || echo 'file does not exist!'
'[' or test command.
test -z "${1}" || echo 'empty.'
test ! -z "${2}" && echo 'non-empty.'
test -n "${1}" || echo 'empty.'
test -n "${1}" && echo 'non-empty.'
test -f /tmp/some-file-1 || nano /tmp/some-file-1
test ! -f /tmp/some-file-2 && nano /tmp/some-file-2
test -d /tmp/some-directory || mkdir /tmp/some-directory
test "${1}" == "${2}" || echo 'non equal.'
test "${1}" != "${2}" && echo 'non equal.'
test "${1}" -lt "${2}" && echo 'lesser.'
test "${2}" -lt "${2}" || echo 'greater.'
Command grouping and sub-shells.
<command> [arguments] ...
<command> [arguments] ...
cat /tmp/expected-file-2 || {
echo 'file does not exist; creating...'
sleep 5
nano /tmp/expected-file-2
(exit 1) || echo 'sub-shell failed!'
{ exit 1 ; } || echo 'block failed!'
Loops and branches.
if.
if <command> <argument> ... ; then { <command> <argument> ... ; } ... else { <command> <argument> ... ; } fi
if <command> <argument> ...
then
<command> <argument> ...
else
<command> <argument> ...
fi
if test ! -f /tmp/expected-file-3 ; then touch /tmp/expected-file-3 ; fi
if test ! -f /tmp/expected-file-4
then
echo 'file does not exit; creating...'
touch /tmp/expected-file-4
sleep 1
nano /tmp/expected-file-4
else
echo 'file exists.'
fi
case.
case <string> in
(<pattern> { | <pattern> } ...)
<command> <argument> ...
;;
esac
case "${1}" in
(start)
echo 'starting daemon...'
daemon &
(stop)
echo 'stopping daemon...'
killall daemon
(*)
echo "unknown action ${1}!"
esac
for.
for <variable> in <string> ... ; do { <command> <argument> ... ; } ... done
for <variable> in <string> ...
do
<command> <argument> ...
done
for a in 1 2 3 4 ; do echo "${a}" ; done
for a in 1 2 3 4
do
echo "${a}"
done
for file in ./.bash* ; do nano "${file}" ; done
for file in ./.bash*
do
echo "editing file ${file}..."
sleep 5
nano "${file}"
done
while.
while <command> <argument> ... ; do { <command> <argument> ... ; } ... done
while <command> <argument> ...
do
<command> <argument> ...
done
while read variable ; do { <command> <argument> ... ; } ... done
while read variable
do
<command> <argument> ...
done
while test ! -f /tmp/expected-file-5 ; do sleep 1 ; done
while test ! -f /tmp/expected-file-5
do
echo 'file does not exit; waiting to be created...'
sleep 1
done
find /etc -type f | while read file
do
echo "found file ${file}."
done
|
323352
|
147
|
https://en.wikiversity.org/wiki?curid=323352
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory 5
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
Command substitution.
`<command> [argument] ...`
$(<command> [argument] ...)
WORKING=`pwd`
WORKING=$(pwd)
WORKING="$(pwd)"
DATE=`date`
DATE=$(date)
DATE="$(date)"
PASSWD="$(cat /etc/passwd)"
echo "${PASSWD}"
Mini projects.
System users and groups querying.
$ ./query.sh show-users
root
bin
fetchmail
ciprian
$ ./query.sh show-valid-users
root
ciprian
$ ./query.sh show-groups
root
daemon
audio
$ ./query.sh show-users-in-group audio
root
ciprian
$ ./query.sh show-groups-for-user ciprian
ciprian
audio
cdrom
$ ./query.sh show-home-for-user ciprian
/home/ciprian
Syslog querying.
$ ./query.sh show-from-host router
May 10 20:20:08 router kernel: Enabling...
May 10 20:20:08 router sshd: Starting...
$ ./query.sh show-from-component kernel
May 10 20:20:08 router kernel: Enabling...
$ ./query.sh show-from-host-and-component router kernel
May 10 20:20:08 router sshd: Starting...
$ ./query.sh search ACPI
May 10 20:20:08 router kernel: Enabling ACPI...
|
323357
|
147
|
https://en.wikiversity.org/wiki?curid=323357
|
Operating systems 1 -- 2008-2009 -- info.uvt.ro/Laboratory tools
|
Quick links: front; laboratories agenda, 1, 2, 3, 4, 5, 6, projects, evaluation, tools, references.
SSH client.
Putty.
Please consult .
Manual pages.
Please consult .
|
323359
|
147
|
https://en.wikiversity.org/wiki?curid=323359
|
Operating systems 1 -- 2009-2010 -- info.uvt.ro
|
Quick links:
Laboratories.
Agenda.
Please consult the dedicated page.
Evaluation.
Please consult the dedicated page.
Tools.
Please consult the dedicated page.
Projects.
Please also consult the dedicated page.
Repository.
Please consult the dedicated page.
|
323370
|
147
|
https://en.wikiversity.org/wiki?curid=323370
|
Operating systems 1 -- 2009-2010 -- info.uvt.ro/Project 1
|
Quick links:
Description.
Implement a C application that implements a basic shell that presents a prompter to the user and allows him to enter certain commands (the commands with their syntax and semantics are described in the next section);
The shell should implement the following basic loop:
Syntax.
Rules:
Examples:
Commands.
exit.
exit
echo.
echo 'a bb cc' cc d "ee ff"
a bb cc cc d ee ff
echoenv.
echoenv USER
ciprian
echoenv NO_SUCH_VARIABLE
[ee] the environment variable `NO_SUCH_VARIABLE` is undefined;
cd, and pwd.
$ pwd
/home/ciprian
$ cd /tmp
$ pwd
/tmp
mkdir, and rmdir.
$ mkdir /tmp
[ee] the folder `/tmp` already exists;
$ mkdir /tmp/a /tmp/b /tmp/c
$ rmdir /tmp/a /tmp/b
$ rmdir /tmp/c
$ rmdir /tmp/x
[ee] the folder `/tmp/x` does not exist;
touch, link, and unlink.
$ touch /tmp/a /tmp/b
$ link /tmp/b /tmp/c
$ unlink /tmp/c
cat, head and tail.
$ cat /etc/fstab /etc/services
... the content of /etc/fstab
... the content of /etc/services
$ head -n 20 /etc/services
... the first 20 lines from /etc/services
ls.
$ ls /
dev
etc
tmp
var
$ ls -a /home/ciprian
.bashrc
.bash_login
desktop
$ ls -l /boot
grub folder 0 0 4096
vmlinuz file 0 0 13341253
Notes.
Mandatory observations:
Optional observations:
Submission.
Please consult the repository page.
|
323378
|
147
|
https://en.wikiversity.org/wiki?curid=323378
|
Prolog EN -- Laboratory 1 -- 2006-2007 -- info.uvt.ro
|
Syntax.
Atoms.
john_smith
nil
x25
<-->
'John Smith'
'X25'
Numbers.
Examples:
78
73.2
-54
-39.7
Variables.
Strings of letters, digits and underscore starting with an upper-case letter or an underscore.
Examples:
X
List
_x25
_
Structures.
Syntax:
<functor>(<argument-1>, <argument-2>, ..., <argument-n>)
A functor is any atom and represents the "name" of the structure. The functor has an arity -- the number of arguments.
An argument is any atom, number, or other structure.
Examples:
date(1, may, 2007)
person('John', 'Smith', date(23, october, 1976))
point(1, 1)
segment(point(1, 1), point(1, 3))
triangle(point(1, 1), point(1, 3), point(2, 3))
+(1, *(2, 3))
.(a, .(b, .(c, [])))
Lists.
A list is nothing else than a composed structure.
Syntax:
.(<element-1>, .(<element-2>, ... .(<element-n>, []) ...))
or
[<element-1>, <element-2>, ..., <element-n>]
Examples:
[1, 2, 3]
[a, b, c, d]
[1, b, 3, d]
[[1, 2], [3, 4], d]
Facts.
Syntax:
<relation>(<argument-1>, <argument-2>, ..., <argument-n>).
A relation is an atom and represents the name of the relation. Each relation has an arity -- the number of arguments.
An argument is any atom, number, or structure.
Example:
on(switch).
working(switch).
working(bulb).
We can observe that relations have the same syntax as structures.
We read each fact as:
We also can observe that facts can be seen as predicates that state something about their subjects (the arguments).
Rules.
Syntax:
<rule>(<argument-1>, <argument-2>, ..., <argument-n>) :-
<clause-1>,
<clause-2>,
<clause-n>.
Where clause can be a fact or another rule.
The comma , stands for and.
Example:
on(light) :- working(switch), working(bulb), on(switch).
off(light) :- off(switch).
We read the rules above as:
We can observe that:
First example -- Genealogical Tree.
Creating and loading the fact file.
Create a fact file (ex-1.prolog):
parent(tom, liz).
parent(bob, ann).
parent(bob, pat).
parent(pat, jim).
Start GNU prolog:
gprolog
Load the facts file:
consult('ex-1.prolog').
Querying the facts.
The most simple query:
parent(tom, liz). %=> yes
parent(tom, ann). %=> no
Queries using variables:
parent(tom, C). %=> C = liz
parent(bob, C). %=> C = ann; C = pat
parent(P, C). %=> P = tom, C = liz; P = bob, C = ann; ...
parent(_, C). %=> C = liz; C = ann; C = pat; C = jim
parent(P, _). %=> P = tom; P = bob; P = bob; P = pat
parent(_, _). %=> true; true; true; true
"Joined" queries:
parent(tom, C), parent(C, GC). %=> no
parent(bob, C), parent(C, GC). %=> C=pat, GC=jim
Unification.
Example:
X = a. %=> X = a
X = Y. %=> Y = X
a = b. %=> no
X = human(john). %=> X = human(john)
human(Name) = human(john). %=> Name = john
Human = human(Name), Name = john. %=> Human = human(john), Name = john.
Resolution.
Example:
parent(P, C). %=> P = tom, C = liz; P = bob, C = ann; ...
Second example -- Genealogical tree with queries.
Adding rules to the fact file.
We add some more facts at the end of the fact file:
male(tom).
male(bob).
male(jim).
female(liz).
female(pat).
female(ann).
And we add the following rules at the end of the fact file (after all the facts):
child(C, P) :- parent(P, C).
father(P, C) :- parent(P, C), male(P).
mother(P, C) :- parent(P, C), female(P).
son(C, P) :- child(C, P), male(C).
daughter(C, P) :- child(C, P), female(C).
brother(A, B) :- son(A, P), son(B, P).
sister(A, B) :- daughter(A, P), daughter(B, P).
grandparent(G, C) :- child(P, G), child(C, P).
ancestor(A, C) :- parent(A, C).
ancestor(A, C) :- parent(A, P), ancestor(P, C).
Querying the rules.
father(P, C). %=> P = tom, C = liz; P = bob, C = ann; P = bob, C = ann
grandparent(G, C). %=> G = bob, C = jim
sister(A, B). %=> A = liz, B = liz; A = ann, B = ann; A = ann, B = pat; A = pat, B = ann; A = pat, B = pat
ancestor(bob, C). %=> C = ann; C = pat; C = jim
[email protected]
[[Category:Prolog]]
|
323379
|
147
|
https://en.wikiversity.org/wiki?curid=323379
|
Prolog EN -- Laboratory 2 -- 2006-2007 -- info.uvt.ro
|
The contents of this section is structured base on the GNU Prolog Manual.
Directives.
consult.
The consult directive is used to load a program from a source file.
Syntax:
consult(user). %=> Allows us to enter the source code by hand ending by pressing Control+D
consult(<file-name>). %=> Tries to load the given file in the current folder. (The file must have the .pl extension.)
If in the source code appears a predicate (either a fact or a rule) that was already defined, the previous definition is discarded.
Example:
consult(user).
e(1).
e(2).
«Control+D»
%=> Loads the facts for the predicate e.
consult(ex1). %=> Loads all the predicates (facts and rules) from the file 'ex1.pl' in the current folder.
load.
The load directive is used to load a compiled file. It behaves just like consult. The source files are compiled by using gplc.
listing.
The listing directive is used to list all or a selection of the loaded predicates (facts and rules).
Syntax:
listing. %=> Lists all the known predicates.
listing(<predicate>). %=> Lists all the predicates with the given functor.
Example:
listing.
% e(1).
% e(2).
% f(a).
% f(b).
listing(f).
% f(a).
% f(b).
halt.
The halt directive is used to exit from the interpreter.
Syntax and example:
halt.
Control structures.
true, fail, and !
These are built-in predicates but act more as control structures:
Syntax and example:
true. %=> yes
fail. %=> no
!. %=> yes
, -- conjunction, ; -- disjunction, and -> -- if-then.
Syntax:
Goal1, Goal2.
Goal1; Goal2.
Example:
atom(a), number(1). %=> yes
atom(a), number(a). %=> no
atom(a); number(a). %=> yes
atom(1); number(1). %=> yes
atom(1), number(1). %=> no
atom(1), number(1). %=> no
abort.
The abort directive (or predicate) is used to abort the current running query.
for.
For is used to iterate a given variable over a range.
Syntax:
for(<iterator>, <lower-bound>, <upper-bound>).
Example:
for(X, 1, 10). %=> X = 1; X = 2; ...; X = 10
\+.
This predicate is used to negate a goal. It succeeds if the following goal fails, and fails otherwise.
Syntax:
\+ <goal>.
Example:
\+ member(1, [1, 2, 3]). %=> no
\+ 1 = 2. %=> yes
Predicates.
Type predicates.
The following predicates are used to determine if the given argument has a certain type.
Syntax:
var(<expression>).
atom(<expression>).
Examples:
var(X). %=> yes
X = 1, var(X). %=> no
list([1, 2, 3]). %=> yes
list([1, A, B]). %=> yes
list([1 | A]). %=> no
Unification predicates = and \=.
Syntax:
<expression-1> = <expression-2>.
<expression-1> \= <expression-2>.
Examples:
1 = 1. %=> yes
a = a. %=> yes
1 + 2 = 3 %=> no
1 + 2 = A %=> A = 1 + 2
A = B %=> A = B
1 \= 2. %=> yes
1 \= A. %=> no
Arithmetic.
Arithmetic operators.
The following operators are the standard operators found in other programming languages.
Syntax:
+ E
- E
E1 + E2
E1 - E2
E1 * E2
E1 / E2
E1 // E2 -- integer division
E1 rem E2
E1 mod E2
E1 ** E2 -- power raising
E1 /\ E2 -- bitwise and
E1 \/ E2 -- bitwise or
E1 ^ E2 -- bitwise xor
E1 « E2 -- bitwise left shift
E1 » E2 -- bitwise right shift
inc(E)
dec(E)
abs(E)
sign(E)
floor(E)
ceiling(E)
round(E)
min(E1, E2)
max(E1, E2)
sqrt(E)
exp(E)
log(E)
cos(E)
acos(E)
sin(E)
asin(E)
atan(E)
is -- used to force the evaluation.
=\=
=<
>=
Examples:
1 + 2 = 3. %=> no
1 + 2 is 3. %=> no
3 is 1 + 2. %=> yes
List predicates.
append.
Syntax:
append(<list-1>, <list-2>, <list-1-2>).
Implementation:
append_([], L, L).
append_([H|L1], L2, [H|L]) :- append_(L1, L2, L).
member.
Syntax:
member(<member>, <list>).
Implementation:
member_(M, [M|_]).
member_(M, [_|L]) :- member_(M, L).
reverse.
Syntax:
reverse(<list>, <reversed>).
Implementation:
reverse_([], []).
reverse_([H|L1], R) :- reverse_(L1, R1), append(R1, [H], R).
delete and select.
Syntax:
delete(<list>, <element>, <result>). %=> Removes all the occurrences in the list.
select(<element>, <list>, <result>). %=> Removes only one occurrence in the list.
Implementation:
select_([], _, []).
select_(E, [E|T], T).
select_(E, [H|T], [H|R]) :- select_(E, T, R).
permutation.
Syntax:
permutation(<list>, <permutation>).
Implementation:
permutation_([], []).
permutation_([H|T], P) :- permutation(T, TP), select(H, P, TP).
prefix and suffix.
Syntax:
prefix(<prefix>, <list>).
suffix(<suffix>, <list>).
Implementation:
prefix_([], _).
prefix_([H|P], [H|L]) :- prefix_(P, L).
sublist.
Syntax:
sublist(<sublist>, <list>).
last and nth.
Syntax:
last(<list>, <element>).
nth(<index>, <list>, <element>).
Implementation:
last_([L], L).
last_([_|T], L) :- last_(T, L).
length.
Syntax:
length(<list>).
Implementation.
length_([], 0).
length_([_|T], L) :- length_(T, L1), L is inc(L1).
max_list, min_list, sum_list.
Syntax:
max_list(<list>, <max>).
min_list(<list>, <min>).
sum_list(<list>, <sum>).
sort.
Syntax:
sort(<list>, <sorted>).
Resolution explanation.
[email protected]
|
323381
|
147
|
https://en.wikiversity.org/wiki?curid=323381
|
Prolog EN -- Laboratory 4 -- 2006-2007 -- info.uvt.ro
|
Relations.
Example 1.
The relations database:
has(joe, car(ford, 3, 5000)).
has(joe, car(opel, 2, 6000)).
has(mick, car(toyota, 5, 1000)).
has(mick, car(ford, 2, 2000)).
has(frank, car(reno, 7, 3500)).
has(mike, car(fiat, 4, 2000)).
has(ion, car(dacia, 10, 100)).
The queries:
Example 2.
The relations database:
department(10, accounting, new_york, 7782).
department(20, research, dallas, 7566).
department(30, sales, chicago, 7698).
department(40, operations, new_york, 7839).
employee(7369, smith, clerk, 7902, 20).
employee(7499, allen, salesman, 7698, 30).
employee(7521, ward, salesman, 7698, 30).
employee(7566, jones, manager, 7839, 20).
employee(7654, martin, salesman, 7968, 30).
employee(7698, blake, manager, 7839, 30).
employee(7782, clark, manager, 7839, 10).
employee(7788, scott, analyst, 7566, 20).
employee(7839, king, president, *, 10).
employee(7844, turner, salesman, 7698, 30).
employee(7876, adams, clerk, 7788, 20).
employee(7900, james, clerk, 7698, 30).
employee(7902, ford, analyst, 7566, 20).
employee(7934, miller, clerk, 7782, 10).
The queries:
Binary sorted trees.
insert(X, *, tree(X, *, *)).
insert(Y, T, NT) :- ...
create(List, Tree) :- ...
Example:
create([1, 2, 3], T). %=> T = tree(3, tree(2, tree(1, *, *), *), *).
Graphs.
edge(1,2).
edge(1,4).
edge(1,3).
edge(2,3).
edge(2,5).
edge(3,4).
edge(3,5).
edge(4,5).
The queries:
[email protected]
|
323382
|
147
|
https://en.wikiversity.org/wiki?curid=323382
|
Prolog EN -- Test -- 2006-2007 -- info.uvt.ro
|
Contents.
The test will be next Friday (2007-06-01) during the normal lab hours.
The test will consist of 2 or 3 problems, each requesting to implement a predicate. The time frame (the time allocated to solving the problems) will be 45 minutes.
The predicates needed to be implemented were presented in the following laboratories (or can be a variation of those predicates.)
Evaluation.
Each of the four problems will be evaluated on a scale from 0 to 10, and the guidelines are similar to the ones used for the Lisp test.
Ciprian Dorin Craciun
2007-05-26
[email protected]
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4