### Yacas

One can define a function f which takes one argument, as for example f x: This can be avoided by inserting spaces. After that, we can fill arbitrary fields in this record: If you clicked on both links, both functions should now be defined, and f a calls the one function whereas f a,b calls the other. Sometimes further simplification is not possible and a function returns itself unsimplified, like taking the square root of an integer Sqrt 2. For this we can use Select, which takes as first argument a predicate that should return True if the list item is to be accepted, and False otherwise, and as second argument the list in question: One of the design goals of Yacas was to allow precisely that, definition of a new function with very little effort. Statements should end with a semicolon ; although this is not required in interactive sessions Yacas will append a semicolon at end of line to finish the statement. This feature is very important when writing a larger body of code, where you want to be able to guarantee that there are no unintended side-effects due to two bits of code defined in different files accidentally using the same global variable. The expression starting with Lambda is essentially a prescription for a specific operation, where it is stated that it accepts 2 arguments, and returns the arguments added together. Finally, we might decide to be completely flexible with this important function and also define it as a mathematical operator. When used right, macros can greatly simplify the task of writing a program. The rules are given precedence values 10 and 20, so the first rule will be applied first. Functions always return a result. From a small set of operations on lists, very powerful symbolic manipulation algorithms can be built. Instead of trying to define all possible transformations, Yacas provides a simple and easy to use pattern matching scheme for manipulating expressions according to user-defined rules. This number determines the ordering of precedence for the pattern matching rules, with 0 the lowest allowed precedence value, i. The Yacas journal which you see when you go to the Yacas web site contains examples of calculations done before by others. Before we show how to do the same calculation in a functional style, we need to explain what a pure function is, as you will need it a lot when programming in a functional style. As a little example to wetten your appetite, we define a Hilbert matrix: Functions returning boolean values are called predicates. An example perhaps explains it best. You can use the arrow keys to browse through this list, and then select the intended function to be inserted by pressing enter. We will jump in with an example that should be self-explanatory. The repetitive nature should become apparent. Functions usually have the form f , f x or f x,y,z,