Language Examples
Examples to get knowledge of the Swan language through the modeling of classical problems.
| Name | Description | Language features |
|---|---|---|
| Proportional Integral Controller | Model of a Proportional Integral (PI) controller. | combinatorial operators, sequential operators |
| DC Motor | Model of a Proportional Integral (PI) controller for a Direct Current (DC) motor. | test harness, plant modeling |
| Message Encoding and Decoding | Encoding and decoding a message to be transmitted, using Scade One variant types. | variant type, activate when, operations on arrays |
| Common Operations on Arrays | A collection of usual computations on arrays. | forward, forward and sequential primitives |
| Parity Bit | Computation of the parity bit for a given integer. | bitwise operators, anonymous operator, equational style |
| Blur with 1D-Gaussian Filter | Application of a 1D-Gaussian filter on an array. | forward, pack |
| Cartesian Positions Using Groups | Common computations on positions, in Cartesian coordinates, with groups. | group, initial value |
| Distance Computation Using Library Operators | Model of a distance computation using library operators. | interface declaration, use directive |
| Designing a Traffic Light System with Automatons | Using automatons (State Machines) to design a Traffic Light System. | automaton, enumerate value |
| Full Adder (FA) | Model of a full adder. | binary logical (xor, and, or), mapfold |
| Fast Exponentiation Algorithm | Computing exponentiation efficiently using fold or forward, particularly using exponentiation by squaring. | fold, forward, pre, last, anonymous operator |
| Moving Average | Implementing a moving average using slices, forward, and pack. | forward, pack, fold, array slices, N-ary operator |