Skip to content

Commit

Permalink
chapter 2 section c added.
Browse files Browse the repository at this point in the history
  • Loading branch information
xedin committed Mar 28, 2010
1 parent ffe09da commit 845f493
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions public/javascripts/tutorial.js
Expand Up @@ -52,7 +52,7 @@ Tutorial.prototype = {
this._a = function() {
this.prev = this._annotation;
this.next = this._b;

return P("Chapter 2a - Defining variables.") + BR() +
P("  Gremlin gives you possibility to work with variables.") + BR() +
P("  Variables in Gremlin must be proceeded by a $ character.") +
Expand All @@ -75,7 +75,33 @@ Tutorial.prototype = {
this.prev = this._b;
this.next = this._d;

return P("Chapter 2c.");
return P("Chapter 2c - Using Gremlin build-in functions and data structures (maps, lists).") + BR() +
P(" Gremlin provides build-in functions and data structures which will be very useful while working with graphs.") + BR() +
P("To execute a function you should call it using special format - ”<prefix>:<function_name>(<arg>, ...)”:") + BR() +
PLIST("g:print('hello world!') - will execute build-in print function.") + BR() +
P("or without arguments:") + BR() +
PLIST("g:print() - will print empty string.") + BR() +
P("There are functions which could be referenced without <prefix> - global functions - like: null(), false(), true()") + BR() +
PLIST("$foo := false() - value returned by false() will be assigned to $foo variable.") + BR() +

P(" Gremlin has own implementation of Map and List data structures (will be familiar to Java developers):") + BR() +
PLIST("g:map(<key>, <value>, ...) - function used to construct map objects:") +
PLIST("g:map('foo', 'bar') - will return {'foo'='bar'} map.") + BR() +
P("the same goes for List:") + BR() +
PLIST("g:list(<value>,...) - function used to construct list objecs:") +
PLIST("g:list(1,2,3,4) - will return [1.0, 2.0, 3.0, 4.0].") + BR() +
P("result of map or list function could be assigned to a variable:") + BR() +
PLIST("$foo := g:map('foo', 'bar')") +
PLIST("$foo := g:list('foo', 'bar')") + BR() +
P("to get value from map use g:get(element, string) function:") + BR() +
PLIST("g:get(g:map('foo', 'bar'), 'foo') - returns 'bar'") + BR() +
P("g:get(list, number) function used to get values from list:") + BR() +
PLIST("g:get(g:list(3, 4), 1) - returns '3.0'") + BR() +
P("to assign new elements to map use g:assign(map,object,object) function:") + BR() +
PLIST("$foo := g:map('foo', 'bar')") +
PLIST("g:assign($foo, 'foo2', 'bar2') - returns 'bar2'") +
PLIST("g:print($foo) - returns {foo2=bar2, foo=bar}") + BR() +
P("Gremlin Function Library Reference could be found " + LINK("http://wiki.github.com/tinkerpop/gremlin/gremlin-function-library", "here"));
}

this._d = function() {
Expand Down

0 comments on commit 845f493

Please sign in to comment.