SlideShare a Scribd company logo
Introduction to Gura Programming Language
www.gura-lang.org
Copyright © 2014 ypsitau@nifty.com
LL Diver on Aug 23, 2014
Copyright (C) 2014 ypsitau 2/49
Author
Name Yutaka Saito
Experience Embedded Firmware to GUI
Job History Electric-app maker, chip maker, venture
Current Job Free, unemployed rather
Favorite Lang C++, Gura
devoted to Gura
Copyright (C) 2014 ypsitau 3/49
Extension Module
Iterator Operation
Basic Specification
What's Gura?
Agenda
What's Gura?
Copyright (C) 2014 ypsitau 4/49
What's Gura?
Repeat processes appear in programs so often.
for (i = 0; i < 10; i++) {
}
people.each do |person|
end
for x in range(10):
hoge
Can I deal them without verbose control sequence?
Copyright (C) 2014 ypsitau 5/49
Case Study (1)
Here's a number sequence: -3, -2, -1, 0, 1, 2, 3.
Make a list of squared values of them.
Think it with your
favorite language ...
x
y
Copyright (C) 2014 ypsitau 6/49
Gura's Program (1)
x = [-3, -2, -1, 0, 1, 2, 3]
y = x * x
Copyright (C) 2014 ypsitau 7/49
Gura's Program (1)
x = [-3, -2, -1, 0, 1, 2, 3]
y = x * x
Multiplying iterator is generated.
Its evaluation creates list.
Iterator Lists generate iterators.1
2
3Evaluation
List List
Iterator
Iterator
List
Copyright (C) 2014 ypsitau 8/49
Case Study (2)
Create a program that reads a text file and prints
its content along with line numbers.
Think it with your
favorite language …
1: #include <std
2: int main()
3: {
4: printf(“H
5: }
Copyright (C) 2014 ypsitau 9/49
Gura's Program (2)
printf('%d: %s',
1.., readlines('hello.c'))
Copyright (C) 2014 ypsitau 10/49
Gura's Program (2)
printf('%d: %s',
1.., readlines('hello.c'))
Iterator that executes printf
for each item is generated.
It's destroyed after evaluated.
1
2
Iterator Iterator
Iterator
Evaluation
Copyright (C) 2014 ypsitau 11/49
After All, Gura is ..
A language that can generate iterators
from iterators and evaluate them.
Gura calls this operation “Mapping”.
Iterator
Iterator
Iterator
Iterator
Iterator Iterator
Iterator Evaluation
Copyright (C) 2014 ypsitau 12/49
Expected Benefits
Simplifies codes of repeat process.
Facilitates parallel computing, maybe.
1
2
Copyright (C) 2014 ypsitau 13/49
Idea for Parallel Computing
Elements in iterator generated last
Iterator generation
requires less load.
Evaluation stage
needs much load.
Distributes elements
to processors
for evaluation.
Eval
Iterator
Iterator
Iterator
Iterator
Iterator Iterator
Iterator Evaluation
Eval Eval
Copyright (C) 2014 ypsitau 14/49
Extension Module
Iterator Operation
Basic Specification
What's Gura?
Agenda
Basic Specification
Copyright (C) 2014 ypsitau 15/49
Basic Specification
Function
Control Sequence
OOP
Collection
Scope Management
Copyright (C) 2014 ypsitau 16/49
Basic Spec (1) Function
x = f(a => 3, b => 4)
f(a:number, b:number) = {
a * a + b * b
}
x = f(3, 4)
Definition (1)
Call
Type can be specified
Named arguments
Copyright (C) 2014 ypsitau 17/49
Basic Spec(1) Function
f(3) // a=3, b=[]
f(3, 1) // a=3, b=[1]
f(3, 1, 4, 1) // a=3, b=[1,4,1]
f(a, b*) = {
// any job
}
Call
Definition (2) Variable-length argument that
takes more than 0 value.
b+ takes more than 1 value.
Copyright (C) 2014 ypsitau 18/49
Basic Spec(1) Function
my_loop(n) {block} = {
while (n > 0) {
block()
n -= 1
}
}
my_loop(3) {
println('hello')
}
Definition (3)
Call
Takes block expression as function object.
{block?} means an optional block.
Copyright (C) 2014 ypsitau 19/49
Basic Spec(2) Control Sequence
if (…) {
} elsif (…) {
} elsif (…) {
} else {
}
try {
} catch (…) {
} catch (…) {
}
for (…) {
}
repeat (…) {
}
while (…) {
}
Repeat Branch Exception
cross (…) {
}
Copyright (C) 2014 ypsitau 20/49
Basic Spec(3) OOP
Fruit = class {
__init__(name:string, price:number) = {
this.name = name
this.price = price
}
Print() = {
printf('%s %dn', this.name, this.price)
}
}
fruit = Fruit('Orange', 90)
fruit.Print()
Class Definition
Instantiation and Method Call
Constructor
Copyright (C) 2014 ypsitau 21/49
Basic Spec(3) OOP
A = class {
__init__(x, y) = {
// any jobs
}
}
B = class(A) {
__init__(x, y, z) = {|x, y|
// any jobs
}
}
Inheritance
Arguments for
base class constructor
Copyright (C) 2014 ypsitau 22/49
Basic Spec(4) Collection
a = [3, 1, 4, 1, 5, 9]
b = ['zero', 'one', 2, 3, 'four', 5]
c = %{ `a => 3, `b => 1, `c => 4 }
d = %{
'いぬ' => 'dog', 'ねこ' => 'cat'
}
List
Dictionary
Copyright (C) 2014 ypsitau 23/49
Basic Spec(5) Scope Management
create_counter(n:number) = {
function {
n -= 1
}
}
c = create_counter(4)
c() // returns 3
c() // returns 2
c() // returns 1
Closure
Each function has lexical scope.
Copyright (C) 2014 ypsitau 24/49
Extension Module
Iterator Operation
Basic Specification
What's Gura?
Agenda
Iterator Operation
Copyright (C) 2014 ypsitau 25/49
Iterator Operation
Implicit Mapping
Member Mapping
Function
Repeat Control
Mapping
Generation
Iterator Operation: Mapping and Generation
Iterator
Iterator
Iterator
Iterator
Iterator
Copyright (C) 2014 ypsitau 26/49
Gura's List and Iterator
List
Iterator
['apple', 'orange', 'grape']
('apple', 'orange', 'grape')
All the elements are stored in memory.
Each element would be generated.
Capable of random access
Only evaluation could make next element available
Copyright (C) 2014 ypsitau 27/49
Gura's List and Iterator
Iterator
List Evaluation
Generation
Copyright (C) 2014 ypsitau 28/49
Iterator Operation(1) Implicit Mapping
Generates iterator embedding function or operator
Function
or
Operator
argument values returned value
Implicit Mapping
Iterator
Iterator
Iterator
Iterator
Copyright (C) 2014 ypsitau 29/49
Iterator Operation(1) Implicit Mapping
f(a:number, b:number) = {
a * b
}
Usual Function
f(a:number, b:number):map = {
a * b
}
Mappable Function Specifies attribute :map
Copyright (C) 2014 ypsitau 30/49
Iterator Operation(1) Implicit Mapping
f(3, 4)Number
f([2, 3, 4], [3, 4, 5])List
f((2, 3, 4), (3, 4, 5))Iterator
f(5, (3, 4, 5))Number and
Iterator
Answer: 12
Answer: [6, 12, 20]
Answer: (6, 12, 20)
Answer: (15, 20, 25)
Copyright (C) 2014 ypsitau 31/49
Iterator Operation(1) Implicit Mapping
List
Scalar
Iterator
List
Others
Mapping process depends arguments' data type
Iterator
Categorize
data types
Three rules to apply mapping
Copyright (C) 2014 ypsitau 32/49
Iterator Operation(1) Implicit Mapping
Generates an iterator
if at least one iterator exists in arguments.
Rule 1
Iterator
Iterator
Iterator
List
Iterator
Scalar
Iterator
Iterator
Iterator
Copyright (C) 2014 ypsitau 33/49
Iterator Operation(1) Implicit Mapping
Generates a list if there's no iterator and
at least one list exists in arguments.
Rule 2
List
List
List
Scalar
List
List
Copyright (C) 2014 ypsitau 34/49
Iterator Operation(1) Implicit Mapping
Generates a scalar
if only scalars exist in arguments.
Rule 3
Scalar
Scalar
Scalar
Copyright (C) 2014 ypsitau 35/49
Iterator Operation(2) Member Mapping
Member Mapping
fruits[0] fruits[1] fruits[2]
name name name
Print() Print() Print()
price price price
List of instances
Generates an iterator to access instance members.
Copyright (C) 2014 ypsitau 36/49
Iterator Operation(2) Member Mapping
Member Mapping
fruits[0] fruits[1] fruits[2]
name name name
Print() Print() Print()
price price price
Iterator
Generates an iterator to access instance members.
fruits:*name
fruits:*price
fruits:*Print()
List of instances
Copyright (C) 2014 ypsitau 37/49
Iterator Operation(2) Member Mapping
sum = 0
for (fruit in fruits) {
sum += fruit.price
}
println(sum)
println(fruits:*price.sum())
Prints summation of Fruit instance's member price.Task
Solution1 Using repeat control
Using Member MappingSolution2
Copyright (C) 2014 ypsitau 38/49
Iterator Operation(3) Function
Function A function should return data sequence
by an iterator, not a list.
rtn = readlines('hello.c')
rtn = range(10)
Iterator to generate strings of each line
Iterator to generate numbers from 0 to 9
Design Policy
Iterator
Copyright (C) 2014 ypsitau 39/49
Iterator Operation(3) Function
rtn = readlines('hello.c'):list
rtn = range(10):list
List containing strings of each line
List containing numbers from 0 to 9
List
Call with attribute :list
in order to get a listFunction Iterator
Copyright (C) 2014 ypsitau 40/49
Iterator Operation(4) Repeat Control
Generate an iterator
from repeat control
Repeat Control
values
repeating job
x = for (…):iter {
}
Evaluation result of
repeating job comes to be
the iterator's element
Specify attribute :iter
for
repeat
while
cross
Iterator
Copyright (C) 2014 ypsitau 41/49
Iterator Operation(4) Repeat Control
n = 0
x = for (i in 0..5):iter {
n += i
}
Nothing happens at this time
println(x)
Prints result: 0 1 3 6 10 15
Example of repeat control iterator
Copyright (C) 2014 ypsitau 42/49
Iterator Operation(4) Repeat Control
prime() = {
p = []
for (n in 2..):xiter {
if (!(n % p.each() == 0).or()) {
p.add(n)
n
}
}
}
primes = prime()
Iterator to generate numbers (2, 3, 5, 7..)
Iterator to generate prime numbers
Copyright (C) 2014 ypsitau 43/49
Extension Module
Iterator Operation
Basic Specification
What's Gura?
Agenda
Extension Module
Copyright (C) 2014 ypsitau 44/49
Extension Module
Design Policy
Gura Interpreter itself should have as little dependency
on OS-specific functions and libraries as possible.
It should extend capabilities by importing modules.
Gura Interpreter
Module
ModuleModule
Module
Module
Module
Copyright (C) 2014 ypsitau 45/49
Bundled Modules
GUI
wxWidgets Tk SDL
Graphic Drawing
Cairo OpenGL FreeType
Image Data
JPEG PNG GIF BMP
ICO XPM PPM TIFF
Network
cURL Server
Text Processing
Regular Exp
yamlXMLCSV
markdown
Archive and Compression
TAR ZIP GZIP BZIP
Copyright (C) 2014 ypsitau 46/49
Cooperation between Modules
Gura Interpreter
JPEG PNG GIF BMP ICO XPM PPM TIFF
Cairo OpenGL FreeType wxWidgets Tk SDL
image
Graphic Drawing
Display Output
Read/Write of Image Data
Copyright (C) 2014 ypsitau 47/49
Application Example
[ ID Photo Made at Home - Gura Shot ]
Creates ID photos by extracted face
image from a file of digital camera.
Outputs results in PDF and JPEG.
JPEG image Cairo image JPEG
wxWidgets
Reading File Composing Image Writing File
Output to Display
Copyright (C) 2014 ypsitau 48/49
Thank you
www.gura-lang.org

More Related Content

PPTX
Tensorflow in practice by Engineer - donghwi cha
PDF
Introduction to NumPy for Machine Learning Programmers
PDF
Python for Scientific Computing -- Ricardo Cruz
KEY
Numpy Talk at SIAM
PDF
Effective Numerical Computation in NumPy and SciPy
PDF
Introduction to NumPy (PyData SV 2013)
PPTX
Fourier project presentation
PDF
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
Tensorflow in practice by Engineer - donghwi cha
Introduction to NumPy for Machine Learning Programmers
Python for Scientific Computing -- Ricardo Cruz
Numpy Talk at SIAM
Effective Numerical Computation in NumPy and SciPy
Introduction to NumPy (PyData SV 2013)
Fourier project presentation
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...

What's hot (20)

PDF
A peek on numerical programming in perl and python e christopher dyken 2005
PDF
Intoduction to numpy
PDF
PyTorch for Deep Learning Practitioners
KEY
NumPy/SciPy Statistics
PDF
Numpy tutorial(final) 20160303
PPTX
Python Scipy Numpy
DOCX
BIometrics- plotting DET and EER curve using Matlab
PPT
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
PDF
Python Manuel-R2021.pdf
PDF
Scientific Computing with Python - NumPy | WeiYuan
PDF
Designing Architecture-aware Library using Boost.Proto
PDF
Memory efficient pytorch
PDF
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
PDF
C Programming: Pointer (Examples)
PDF
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
PDF
C Prog - Functions
PDF
Welcome to python
PPTX
Tensor flow (1)
PDF
TensorFlow example for AI Ukraine2016
A peek on numerical programming in perl and python e christopher dyken 2005
Intoduction to numpy
PyTorch for Deep Learning Practitioners
NumPy/SciPy Statistics
Numpy tutorial(final) 20160303
Python Scipy Numpy
BIometrics- plotting DET and EER curve using Matlab
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Python Manuel-R2021.pdf
Scientific Computing with Python - NumPy | WeiYuan
Designing Architecture-aware Library using Boost.Proto
Memory efficient pytorch
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
C Programming: Pointer (Examples)
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
C Prog - Functions
Welcome to python
Tensor flow (1)
TensorFlow example for AI Ukraine2016
Ad

Similar to Introduction to Gura Programming Language (20)

PDF
new-iter-concepts
PDF
Pydiomatic
PDF
Python idiomatico
PDF
The Vanishing Pattern: from iterators to generators in Python
DOC
Time and space complexity
PPTX
CS151 FIle Input and Output
PDF
Ti1220 Lecture 7: Polymorphism
PPTX
Introduction-to-Iteration (2).pptx
PDF
The STL
PDF
Gentle Introduction to Functional Programming
PDF
Functional programming in ruby
PDF
data structures
ZIP
Learning from 6,000 projects mining specifications in the large
PDF
COneShotPart3.pdf1111111111111111111111111
PDF
Data struture and aligorism
PDF
PPSX
Software Metrics
PDF
Peyton jones-2011-type classes
PPTX
C++ Generators and Property-based Testing
new-iter-concepts
Pydiomatic
Python idiomatico
The Vanishing Pattern: from iterators to generators in Python
Time and space complexity
CS151 FIle Input and Output
Ti1220 Lecture 7: Polymorphism
Introduction-to-Iteration (2).pptx
The STL
Gentle Introduction to Functional Programming
Functional programming in ruby
data structures
Learning from 6,000 projects mining specifications in the large
COneShotPart3.pdf1111111111111111111111111
Data struture and aligorism
Software Metrics
Peyton jones-2011-type classes
C++ Generators and Property-based Testing
Ad

Recently uploaded (20)

PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
history of c programming in notes for students .pptx
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Website Design Services for Small Businesses.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Patient Appointment Booking in Odoo with online payment
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Cost to Outsource Software Development in 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
AutoCAD Professional Crack 2025 With License Key
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
Tally Prime Crack Download New Version 5.1 [2025] (License Key Free
Why Generative AI is the Future of Content, Code & Creativity?
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
history of c programming in notes for students .pptx
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Autodesk AutoCAD Crack Free Download 2025
Website Design Services for Small Businesses.pdf
Complete Guide to Website Development in Malaysia for SMEs
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Patient Appointment Booking in Odoo with online payment
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Design an Analysis of Algorithms II-SECS-1021-03
Cost to Outsource Software Development in 2025
Wondershare Filmora 15 Crack With Activation Key [2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
iTop VPN Crack Latest Version Full Key 2025
AutoCAD Professional Crack 2025 With License Key

Introduction to Gura Programming Language

  • 1. Introduction to Gura Programming Language www.gura-lang.org Copyright © 2014 ypsitau@nifty.com LL Diver on Aug 23, 2014
  • 2. Copyright (C) 2014 ypsitau 2/49 Author Name Yutaka Saito Experience Embedded Firmware to GUI Job History Electric-app maker, chip maker, venture Current Job Free, unemployed rather Favorite Lang C++, Gura devoted to Gura
  • 3. Copyright (C) 2014 ypsitau 3/49 Extension Module Iterator Operation Basic Specification What's Gura? Agenda What's Gura?
  • 4. Copyright (C) 2014 ypsitau 4/49 What's Gura? Repeat processes appear in programs so often. for (i = 0; i < 10; i++) { } people.each do |person| end for x in range(10): hoge Can I deal them without verbose control sequence?
  • 5. Copyright (C) 2014 ypsitau 5/49 Case Study (1) Here's a number sequence: -3, -2, -1, 0, 1, 2, 3. Make a list of squared values of them. Think it with your favorite language ... x y
  • 6. Copyright (C) 2014 ypsitau 6/49 Gura's Program (1) x = [-3, -2, -1, 0, 1, 2, 3] y = x * x
  • 7. Copyright (C) 2014 ypsitau 7/49 Gura's Program (1) x = [-3, -2, -1, 0, 1, 2, 3] y = x * x Multiplying iterator is generated. Its evaluation creates list. Iterator Lists generate iterators.1 2 3Evaluation List List Iterator Iterator List
  • 8. Copyright (C) 2014 ypsitau 8/49 Case Study (2) Create a program that reads a text file and prints its content along with line numbers. Think it with your favorite language … 1: #include <std 2: int main() 3: { 4: printf(“H 5: }
  • 9. Copyright (C) 2014 ypsitau 9/49 Gura's Program (2) printf('%d: %s', 1.., readlines('hello.c'))
  • 10. Copyright (C) 2014 ypsitau 10/49 Gura's Program (2) printf('%d: %s', 1.., readlines('hello.c')) Iterator that executes printf for each item is generated. It's destroyed after evaluated. 1 2 Iterator Iterator Iterator Evaluation
  • 11. Copyright (C) 2014 ypsitau 11/49 After All, Gura is .. A language that can generate iterators from iterators and evaluate them. Gura calls this operation “Mapping”. Iterator Iterator Iterator Iterator Iterator Iterator Iterator Evaluation
  • 12. Copyright (C) 2014 ypsitau 12/49 Expected Benefits Simplifies codes of repeat process. Facilitates parallel computing, maybe. 1 2
  • 13. Copyright (C) 2014 ypsitau 13/49 Idea for Parallel Computing Elements in iterator generated last Iterator generation requires less load. Evaluation stage needs much load. Distributes elements to processors for evaluation. Eval Iterator Iterator Iterator Iterator Iterator Iterator Iterator Evaluation Eval Eval
  • 14. Copyright (C) 2014 ypsitau 14/49 Extension Module Iterator Operation Basic Specification What's Gura? Agenda Basic Specification
  • 15. Copyright (C) 2014 ypsitau 15/49 Basic Specification Function Control Sequence OOP Collection Scope Management
  • 16. Copyright (C) 2014 ypsitau 16/49 Basic Spec (1) Function x = f(a => 3, b => 4) f(a:number, b:number) = { a * a + b * b } x = f(3, 4) Definition (1) Call Type can be specified Named arguments
  • 17. Copyright (C) 2014 ypsitau 17/49 Basic Spec(1) Function f(3) // a=3, b=[] f(3, 1) // a=3, b=[1] f(3, 1, 4, 1) // a=3, b=[1,4,1] f(a, b*) = { // any job } Call Definition (2) Variable-length argument that takes more than 0 value. b+ takes more than 1 value.
  • 18. Copyright (C) 2014 ypsitau 18/49 Basic Spec(1) Function my_loop(n) {block} = { while (n > 0) { block() n -= 1 } } my_loop(3) { println('hello') } Definition (3) Call Takes block expression as function object. {block?} means an optional block.
  • 19. Copyright (C) 2014 ypsitau 19/49 Basic Spec(2) Control Sequence if (…) { } elsif (…) { } elsif (…) { } else { } try { } catch (…) { } catch (…) { } for (…) { } repeat (…) { } while (…) { } Repeat Branch Exception cross (…) { }
  • 20. Copyright (C) 2014 ypsitau 20/49 Basic Spec(3) OOP Fruit = class { __init__(name:string, price:number) = { this.name = name this.price = price } Print() = { printf('%s %dn', this.name, this.price) } } fruit = Fruit('Orange', 90) fruit.Print() Class Definition Instantiation and Method Call Constructor
  • 21. Copyright (C) 2014 ypsitau 21/49 Basic Spec(3) OOP A = class { __init__(x, y) = { // any jobs } } B = class(A) { __init__(x, y, z) = {|x, y| // any jobs } } Inheritance Arguments for base class constructor
  • 22. Copyright (C) 2014 ypsitau 22/49 Basic Spec(4) Collection a = [3, 1, 4, 1, 5, 9] b = ['zero', 'one', 2, 3, 'four', 5] c = %{ `a => 3, `b => 1, `c => 4 } d = %{ 'いぬ' => 'dog', 'ねこ' => 'cat' } List Dictionary
  • 23. Copyright (C) 2014 ypsitau 23/49 Basic Spec(5) Scope Management create_counter(n:number) = { function { n -= 1 } } c = create_counter(4) c() // returns 3 c() // returns 2 c() // returns 1 Closure Each function has lexical scope.
  • 24. Copyright (C) 2014 ypsitau 24/49 Extension Module Iterator Operation Basic Specification What's Gura? Agenda Iterator Operation
  • 25. Copyright (C) 2014 ypsitau 25/49 Iterator Operation Implicit Mapping Member Mapping Function Repeat Control Mapping Generation Iterator Operation: Mapping and Generation Iterator Iterator Iterator Iterator Iterator
  • 26. Copyright (C) 2014 ypsitau 26/49 Gura's List and Iterator List Iterator ['apple', 'orange', 'grape'] ('apple', 'orange', 'grape') All the elements are stored in memory. Each element would be generated. Capable of random access Only evaluation could make next element available
  • 27. Copyright (C) 2014 ypsitau 27/49 Gura's List and Iterator Iterator List Evaluation Generation
  • 28. Copyright (C) 2014 ypsitau 28/49 Iterator Operation(1) Implicit Mapping Generates iterator embedding function or operator Function or Operator argument values returned value Implicit Mapping Iterator Iterator Iterator Iterator
  • 29. Copyright (C) 2014 ypsitau 29/49 Iterator Operation(1) Implicit Mapping f(a:number, b:number) = { a * b } Usual Function f(a:number, b:number):map = { a * b } Mappable Function Specifies attribute :map
  • 30. Copyright (C) 2014 ypsitau 30/49 Iterator Operation(1) Implicit Mapping f(3, 4)Number f([2, 3, 4], [3, 4, 5])List f((2, 3, 4), (3, 4, 5))Iterator f(5, (3, 4, 5))Number and Iterator Answer: 12 Answer: [6, 12, 20] Answer: (6, 12, 20) Answer: (15, 20, 25)
  • 31. Copyright (C) 2014 ypsitau 31/49 Iterator Operation(1) Implicit Mapping List Scalar Iterator List Others Mapping process depends arguments' data type Iterator Categorize data types Three rules to apply mapping
  • 32. Copyright (C) 2014 ypsitau 32/49 Iterator Operation(1) Implicit Mapping Generates an iterator if at least one iterator exists in arguments. Rule 1 Iterator Iterator Iterator List Iterator Scalar Iterator Iterator Iterator
  • 33. Copyright (C) 2014 ypsitau 33/49 Iterator Operation(1) Implicit Mapping Generates a list if there's no iterator and at least one list exists in arguments. Rule 2 List List List Scalar List List
  • 34. Copyright (C) 2014 ypsitau 34/49 Iterator Operation(1) Implicit Mapping Generates a scalar if only scalars exist in arguments. Rule 3 Scalar Scalar Scalar
  • 35. Copyright (C) 2014 ypsitau 35/49 Iterator Operation(2) Member Mapping Member Mapping fruits[0] fruits[1] fruits[2] name name name Print() Print() Print() price price price List of instances Generates an iterator to access instance members.
  • 36. Copyright (C) 2014 ypsitau 36/49 Iterator Operation(2) Member Mapping Member Mapping fruits[0] fruits[1] fruits[2] name name name Print() Print() Print() price price price Iterator Generates an iterator to access instance members. fruits:*name fruits:*price fruits:*Print() List of instances
  • 37. Copyright (C) 2014 ypsitau 37/49 Iterator Operation(2) Member Mapping sum = 0 for (fruit in fruits) { sum += fruit.price } println(sum) println(fruits:*price.sum()) Prints summation of Fruit instance's member price.Task Solution1 Using repeat control Using Member MappingSolution2
  • 38. Copyright (C) 2014 ypsitau 38/49 Iterator Operation(3) Function Function A function should return data sequence by an iterator, not a list. rtn = readlines('hello.c') rtn = range(10) Iterator to generate strings of each line Iterator to generate numbers from 0 to 9 Design Policy Iterator
  • 39. Copyright (C) 2014 ypsitau 39/49 Iterator Operation(3) Function rtn = readlines('hello.c'):list rtn = range(10):list List containing strings of each line List containing numbers from 0 to 9 List Call with attribute :list in order to get a listFunction Iterator
  • 40. Copyright (C) 2014 ypsitau 40/49 Iterator Operation(4) Repeat Control Generate an iterator from repeat control Repeat Control values repeating job x = for (…):iter { } Evaluation result of repeating job comes to be the iterator's element Specify attribute :iter for repeat while cross Iterator
  • 41. Copyright (C) 2014 ypsitau 41/49 Iterator Operation(4) Repeat Control n = 0 x = for (i in 0..5):iter { n += i } Nothing happens at this time println(x) Prints result: 0 1 3 6 10 15 Example of repeat control iterator
  • 42. Copyright (C) 2014 ypsitau 42/49 Iterator Operation(4) Repeat Control prime() = { p = [] for (n in 2..):xiter { if (!(n % p.each() == 0).or()) { p.add(n) n } } } primes = prime() Iterator to generate numbers (2, 3, 5, 7..) Iterator to generate prime numbers
  • 43. Copyright (C) 2014 ypsitau 43/49 Extension Module Iterator Operation Basic Specification What's Gura? Agenda Extension Module
  • 44. Copyright (C) 2014 ypsitau 44/49 Extension Module Design Policy Gura Interpreter itself should have as little dependency on OS-specific functions and libraries as possible. It should extend capabilities by importing modules. Gura Interpreter Module ModuleModule Module Module Module
  • 45. Copyright (C) 2014 ypsitau 45/49 Bundled Modules GUI wxWidgets Tk SDL Graphic Drawing Cairo OpenGL FreeType Image Data JPEG PNG GIF BMP ICO XPM PPM TIFF Network cURL Server Text Processing Regular Exp yamlXMLCSV markdown Archive and Compression TAR ZIP GZIP BZIP
  • 46. Copyright (C) 2014 ypsitau 46/49 Cooperation between Modules Gura Interpreter JPEG PNG GIF BMP ICO XPM PPM TIFF Cairo OpenGL FreeType wxWidgets Tk SDL image Graphic Drawing Display Output Read/Write of Image Data
  • 47. Copyright (C) 2014 ypsitau 47/49 Application Example [ ID Photo Made at Home - Gura Shot ] Creates ID photos by extracted face image from a file of digital camera. Outputs results in PDF and JPEG. JPEG image Cairo image JPEG wxWidgets Reading File Composing Image Writing File Output to Display
  • 48. Copyright (C) 2014 ypsitau 48/49 Thank you www.gura-lang.org