Language Examples

Examples to get knowledge of the Swan language through the modeling of classical problems.

NameDescriptionLanguage features
Proportional Integral ControllerModel of a Proportional Integral (PI) controller.combinatorial operators, sequential operators
DC MotorModel of a Proportional Integral (PI) controller for a Direct Current (DC) motor.test harness, plant modeling
Message Encoding and DecodingEncoding and decoding a message to be transmitted, using Scade One variant types. variant type, activate when, operations on arrays
Common Operations on ArraysA collection of usual computations on arrays.forward, forward and sequential primitives
Parity BitComputation of the parity bit for a given integer.bitwise operators, anonymous operator, equational style
Blur with 1D-Gaussian FilterApplication of a 1D-Gaussian filter on an array.forward, pack
Cartesian Positions Using GroupsCommon computations on positions, in Cartesian coordinates, with groups.group, initial value
Distance Computation Using Library OperatorsModel of a distance computation using library operators.interface declaration, use directive
Designing a Traffic Light System with AutomatonsUsing 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 AlgorithmComputing exponentiation efficiently using fold or forward, particularly using exponentiation by squaring.fold, forward, pre, last, anonymous operator
Moving AverageImplementing a moving average using slices, forward, and pack.forward, pack, fold, array slices, N-ary operator