Logix is not one language but many. When you start Logix, the ‘current language’ will be Standard Logix (std). Python folks might want to switch to a more Python-like syntax:
[std]: setlang logix.baselang
This puts you into Base Logix (base), a Python-like language which Logix can translate into Python byte code. Other Logix languages are generally implemented by translation into Base Logix.
You can now bash away as if you were at the regular Python prompt. There are some differences with Python however. There are some things that work in Base Logix that are not valid Python, and there are some nuances of Python syntax that are not supported.
The main difference with Python is that Logix has an expression-based syntax, which is to say there is no statement/expression distinction. For example, try
[base]: f = lambda x: (print x; x+1)
[base]: f(5)
5
6
As in Python, the lambda expression returns a function. Unlike Python, print also yields an expression (with a side-effect). The ; is an operator that takes two expressions and evaluates them in left-to-right order, returning the result of the second.
The Logix if returns a value:
[base]: x = if 2+2==4: "I thought so" else: "hmmm..."
[base]: x
'I thought so'
From this example you can also see that Logix’s white-space rules differ from Python’s. In fact Logix’s white-space rules are more like those of Haskell (www.haskell.org). In Logix:
Base Logix also has a do operator that allows you to introduce a block of code anywhere you can have an expression. The result of the do is the result of the last expression in the block.
[base]: vals = [3,6,8,2,4,7]
[base]: average = do:
sum = 0
for x in vals: sum += x
float(x) / len(vals)
[base]: average
1.166666666666667
Base Logix does not currently support the following from Python: