[ | smalltalk dot org ].
Community and industry meet inventing the future.
Some Basic F-Script Examples
posted by Peter William Lount
version 1, 20040920 12:30pm PDT

Get the names of the employees:
Smalltalk:
employees collect:[:anEmployee | anEmployee name]

F-Script:
employees name

Get the names of the employees whose age is greater than 30:
Smalltalk:
(employees select:[: anEmployee | anEmployee age > 30]) collect:[: anEmployee | anEmployee name]

F-Script:
employees name at: employees age > 30

Get a list of employees sorted according to their salary:
Smalltalk:
employees asSortedCollection:[:e1 :e2| e1 salary < e2 salary]

F-Script:
employees at: employees salary sort

Increase the salary of each employee by a specific amount:
Smalltalk:
employees with:amounts do:[:anEmployee :anAmount| anEmployee raiseSalary:anAmount]

F-Script:
employees raiseSalary:amounts



Copyright 1999-2010 by Smalltalk.org"!, All Rights Reserved.