Pipes

ASnake Documentation

Table Of Contents

Summary:

Pipes are a syntax shortcut for sending arguments to functions. A normal Python function works like this:

myFunction(myArgument)

ASnake pipes are backwards.

myArgument to myFunction

They are two ways to do the same thing.

Left argument should be a datatype or expression. Right argument should be a function.

Syntax to:

to attempts to wrap the last element only.

It accepts the following: datatypes, variables, functions, parenthesis groups

The following examples are valid:

print '2' to int
# result: 2
4 to str to print
# result: 4
print 1,2,-3 to abs
# result: 1 2 3
(4,5,6) to print
# result: 4 5 6
(14-2) to float to print
# result: 12.0
print [7,8,9] to tuple
# result: (7, 8, 9)

Syntax pipe:

pipe allows you to wrap a to pipe to a specific element point. Thus you can wrap multiple elements instead of just one. You can think of pipe as being a ( and a to being a ).

The following examples are valid:

print pipe 2 + 2 to str
# result: '4'
pipe 4 + 4
to print
# result: 8

Syntax into:

into pipes the entire expression to a function. It will ignore pipe syntax.

The following examples are valid:

1+2+3+4+5+6 into print
# result: 21
'21' to int - 12 into print
# result: 9
pipe 1.4+2.5 to int + 2.1 into int + 2
# result: 7
Scroll to top