Front Page
Main:
Concatenative languages:
Interesting languages:
Computer science:
External:
Meta:
== Listener examples == You can try expressions in the interactive listener. For example, some postfix arithmetic: [{2 3 + 4 * .}] Hello world: [{"Hello world" print}] == Complete examples == === Simple === - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/hello-world/hello-world.factor;hb=HEAD|hello-world]] - a complete program that defines a new vocabulary with a main word === Networking and web === - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/time-server/time-server.factor;hb=HEAD|time-server]] - simple TCP/IP server - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/webapps/calculator;hb=HEAD|webapps.calculator]] - simple webapp - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/webapps/wiki;hb=HEAD|webapps.wiki]] - the source code to this wiki - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/smtp;hb=HEAD|smtp]] - send e-mail via SMTP, with optional SSL support - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/syndication;hb=HEAD|syndication]] - parse RSS and Atom feeds, write Atom feeds, also demonstrates [[http://docs.factorcode.org/content/article-xml.syntax%2cinterpolation.html|inline XML syntax]]. === Algorithms === - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/rot13/rot13.factor;hb=HEAD|rot13]] - rot13 "encryption" - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/roman;hb=HEAD|roman]] - convert numbers to and from roman numerals - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/morse;hb=HEAD|morse]] - convert strings to morse code and vice versa, and play morse code with OpenAL - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/base64;hb=HEAD|base64]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/id3;hb=HEAD|id3]] - ID3 parser - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/usa-cities;hb=HEAD|usa-cities]] - parse a CSV file and extract information - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=extra/benchmark/mandel;hb=HEAD|benchmark.mandel]] - Mandelbrot fractal generator === C library bindings === Many of these bindings have easier to use wrappers (for example, there's no reason to use the Unix API directly, since all I/O is done with higher-level cross-platform APIs). [[http://docs.factorcode.org/content/article-alien.html|Learn more about Factor's C library interface]]. - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/unix;hb=HEAD|unix]] - Unix/POSIX - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/windows;hb=HEAD|windows]] - Win32 - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=tree;f=basis/opengl/gl/gl.factor;hb=HEAD|opengl.gl]] - low-level OpenGL API === Graphics === These examples are more complex than the above, and some of them were written a while ago and haven't been cleaned up to use the latest idioms. They are all runnable from the [[Factor/UI|Factor UI]] if you have a good enough OpenGL driver -- just issue a command such as %"spheres" run% in the listener. - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/hello-unicode/hello-unicode.factor;hb=HEAD|hello-unicode]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/terrain/terrain.factor;hb=HEAD|terrain]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/spheres/spheres.factor;hb=HEAD|spheres]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/bunny/bunny.factor;hb=HEAD|bunny]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/maze/maze.factor;hb=HEAD|maze]] - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/tetris/tetris.factor;hb=HEAD|tetris]] === Comp sci === - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/rpn/rpn.factor;hb=HEAD|rpn]] - Simple reverse polish notation calculator. It implements a parser, "bytecode" instruction set, and simple stack interpreter, from scratch, without re-using parts of Factor's own implementation via reflection. - [[http://gitweb.factorcode.org/gitweb.cgi?p=factor;a=blob;f=extra/monads/monads.factor;hb=HEAD|monads]] - Implements a generic protocol, some operations over monads, and a few simple instances == Running the examples == Some of these examples define a [[http://docs.factorcode.org/content/word-MAIN__colon__%2csyntax.html|MAIN:]] word. This means they are runnable from the Factor listener, by issuing a command such as the following, [{"hello-unicode" run}] Other examples are libraries, which means that after loading them with a command like this: [{USE: roman}] you can then get a list of words, and in some cases, API documentation: [{"roman" about}] and play around: [{( scratchpad ) 123 >roman . "cxxiii"}] == Understanding the examples == If you see an example refer to a vocabulary in its %USING:% list, you can get help for that vocabulary from the Factor listener: [{"math.vectors" about}] The about page gives a list of words with stack effects -- clicking on a word will display documentation for the word, if any, as well as its definition (which may not exactly match the source file definition, since its printed from its in-memory representation). For many vocabularies, a "Documentation" link at the very top gives an overview article as well. If you see an example call a word you're unfamiliar with, make sure you load all required vocabularies by copying the example's %USING:% line into your listener, then use the %help% word to get help: [{\ reverse help}] This even works for bits of syntax: [{\ MEMO: help}] Finally, all of this reference documentation is also available online at [[http://docs.factorcode.org]] [[http://www.shoppharmacycounter.com/t-Adipex-Medicine.aspx|adipex side effects]]. == More == To see more examples of Factor code, [[http://factorcode.org|download]] the Factor distribution and take a look in the %core/%, %basis/% and %extra/% directories. Most of Factor is implemented in Factor (including the optimizing compiler), and there are a number of useful libraries and demos which you can look at as well, for a total of over 200 thousand lines [[http://adipexweightlossdiet.com/fastweightloss.html|quick weight loss]] of Factor code.
Describe this revision:
Save
All content is © 2008-2010 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.