SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

A peek on numerical programming in perl and python e christopher dyken 2005
A peek on numerical programming in perl and python  e christopher dyken  2005A peek on numerical programming in perl and python  e christopher dyken  2005
A peek on numerical programming in perl and python e christopher dyken 2005Jules Krdenas
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpyFaraz Ahmed
 
PyTorch for Deep Learning Practitioners
PyTorch for Deep Learning PractitionersPyTorch for Deep Learning Practitioners
PyTorch for Deep Learning PractitionersBayu Aldi Yansyah
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Namgee Lee
 
BIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabBIometrics- plotting DET and EER curve using Matlab
BIometrics- plotting DET and EER curve using MatlabShiv Koppad
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviEnthought, Inc.
 
Scientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanScientific Computing with Python - NumPy | WeiYuan
Scientific Computing with Python - NumPy | WeiYuanWei-Yuan Chang
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoJoel Falcou
 
Memory efficient pytorch
Memory efficient pytorchMemory efficient pytorch
Memory efficient pytorchHyungjoo Cho
 
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Edureka!
 
C Programming: Pointer (Examples)
C Programming: Pointer (Examples)C Programming: Pointer (Examples)
C Programming: Pointer (Examples)Joongheon Kim
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Peng Cheng
 
C Prog - Functions
C Prog - FunctionsC Prog - Functions
C Prog - Functionsvinay arora
 
Tensor flow (1)
Tensor flow (1)Tensor flow (1)
Tensor flow (1)景逸 王
 
TensorFlow example for AI Ukraine2016
TensorFlow example  for AI Ukraine2016TensorFlow example  for AI Ukraine2016
TensorFlow example for AI Ukraine2016Andrii Babii
 

La actualidad más candente (20)

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

Similar a Introduction to Gura Programming Language

Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docxrafbolet0
 
memory_allocation_use1.ppt
memory_allocation_use1.pptmemory_allocation_use1.ppt
memory_allocation_use1.pptKanchanTiwari45
 
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & GeneratorsPython Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & GeneratorsP3 InfoTech Solutions Pvt. Ltd.
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simpleAteji Px
 
Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directivesVikash Dhal
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2Naveen Kumar
 
Develop Embedded Software Module-Session 3
Develop Embedded Software Module-Session 3Develop Embedded Software Module-Session 3
Develop Embedded Software Module-Session 3Naveen Kumar
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and SparkOswald Campesato
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918Yen_CY
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918Chia-Yi Yen
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programmingYanchang Zhao
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
 

Similar a Introduction to Gura Programming Language (20)

Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docxSpring 2014 CSCI 111 Final exam   of 1 61. (2 points) Fl.docx
Spring 2014 CSCI 111 Final exam of 1 61. (2 points) Fl.docx
 
memory_allocation_use1.ppt
memory_allocation_use1.pptmemory_allocation_use1.ppt
memory_allocation_use1.ppt
 
Using Parallel Computing Platform - NHDNUG
Using Parallel Computing Platform - NHDNUGUsing Parallel Computing Platform - NHDNUG
Using Parallel Computing Platform - NHDNUG
 
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & GeneratorsPython Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
 
Java parallel programming made simple
Java parallel programming made simpleJava parallel programming made simple
Java parallel programming made simple
 
Preprocessor directives
Preprocessor directivesPreprocessor directives
Preprocessor directives
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
markomanolis_phd_defense
markomanolis_phd_defensemarkomanolis_phd_defense
markomanolis_phd_defense
 
Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2Develop Embedded Software Module-Session 2
Develop Embedded Software Module-Session 2
 
Develop Embedded Software Module-Session 3
Develop Embedded Software Module-Session 3Develop Embedded Software Module-Session 3
Develop Embedded Software Module-Session 3
 
Javascript.ppt
Javascript.pptJavascript.ppt
Javascript.ppt
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918
 
[計一] Basic r programming final0918
[計一] Basic r programming   final0918[計一] Basic r programming   final0918
[計一] Basic r programming final0918
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Spsl iv unit final
Spsl iv unit  finalSpsl iv unit  final
Spsl iv unit final
 
Sci py india_conference_2019
Sci py india_conference_2019Sci py india_conference_2019
Sci py india_conference_2019
 
RDataMining slides-r-programming
RDataMining slides-r-programmingRDataMining slides-r-programming
RDataMining slides-r-programming
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 

Último

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 

Último (20)

Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 

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