دسته بندی زبانها بر حسب نوع زبانهای با نوع : (ايستا : ترجمه) – (پويا : تفسير) تفسيری : Snobol، Apl، Awk، Javascript var kate=“hi” var sam=200 val l=10.25.

Slides:



Advertisements
Similar presentations
Brown Bag #2 Advanced C++. Topics  Templates  Standard Template Library (STL)  Pointers and Smart Pointers  Exceptions  Lambda Expressions  Tips.
Advertisements

Template. 2 Using templates, it is possible to create generic functions and classes. In a generic function or class, the type of data upon which the function.
زبان برنامه نویسی پرولوگ
Chapter 17 Templates. Generic Algorithms Algorithms in which the actions or steps are defined, but the data types of the items being manipulated are not.
LCS Non-Dynamic Version int function lcs (x, y, i, j) begin if (i = 0) or (j = 0) return 0; else if (x[i] = y[j]) return lcs(x, y, i-1, j-1)+1; else return.
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
Structures Spring 2013Programming and Data Structure1.
EC-241 Object-Oriented Programming
مهدی آذرنوش مبحث ششم : آرایه ها و رشته ها حسابگری الگوریتمی.
Student Data Score First Name Last Name ID GPA DOB Phone... How to store student data in our programs? 1.
1 Class Vehicle #include #define N 10../.. 2 Class Vehicle class vehicle { public: float speed; char colour[N+1]; char make[N+1];
Union, bitfield, typedef, enum union nama_u{ }; union nama_u{ struct nama_s byte; }; enum{ }; Tipedef var BYTE.
Pseudocode for Bracket matching Stack mystack; // declare & initialize stack Loop through all characters in program { if (symbol is an ‘opener’) // (,
دستور های ورودی خروجی عباسپور 1 دستورهای ورودی و خروجی Input Output Commands.
Slide 1 Where are we, and where to go? Simple types of variables (variables=objects) 3 program structures (assignment, conditional, iteration) Static objects.
Slide 1 Where are we, and where to go? Simple types of variables (variables=objects) 3 program structures (assignment, conditional, iteration) Static objects.
Generic programming Define software components with type parameters –A sorting algorithm has the same structure, regardless of the types being sorted –Stack.
برنامه سازی کامپيوتری 1 نرم افزار در کامپيوتر. برنامه سازی کامپيوتری 2 نرم افزارها سخت افزار کامپيوتر بدون نرم افزار ان غير قابل استفاده است نرم افزار.
1 برنامه سازی با C# برنامه منو Instructor : Saeed Shiry.
Generic programming Define software components with type parameters –A sorting algorithm has the same structure, regardless of the types being sorted –Stack.
برنامه سازی کامپيوتر 1 زبانهای برنامه سازی Programming Languages.
فایل پردازی در C File based Programming in C. انواع فایل متنی –سرعت بالا –حجم کمتر –امکان دسترسی تصادفی –حفظ امنیت داده ها دودویی (باینری) –امکان باز.
Imperative Programming. Heart of program is assignment statements Aware that memory contains instructions and data values Commands: variable declarations,
PHP Hypertext per processor کار می کند؟ PHP چگونه
EEL 3801 Part VIII Fundamentals of C and C++ Programming Template Functions and Classes.
فارسی سازی يکپارچه در سيستم عاملهای OS/390 & Windows واحد 1 مهندسی سيستم Integrated Farsi support on OS/390 & Windows.
Copyright  Hannu Laine C++-programming Part 2 Hannu Laine.
1 Scope Scope describes the region where an identifier is known, and semantic rules for this.
1 بنام خدا زبان برنامه نویسی C (21814( Lecture 14 Structures.
Database Laboratory: Session #4 Akram Shokri. DB-Lab 2 Lab Activity You must already created all tables You have to have inserted proper data in tables.
به نام خدا برنامه سازی سمت سرور (php)
CSI1390 – Java Programming Methods II Instructor: Saeid Nourian
Chapter 3 Templates Saurav Karmakar Spring Objective In Chapter 3, we will discuss: The concept of a template Function templates Class templates.
Principles of Object-Oriented Software Development The language C++
مظفر بگ محمدی دانشگاه ایلام Generics. کدهای عمومی 2 یکی از اهداف OOP ایجاد قابلیت نوشتن برنامه های عمومی با قابلیت استفاده ی مجدد است. کدهای چندریخت تا.
CSI 3125, Preliminaries, page 1 Generic Class & Generic methods.
Java and C++ Transitioning. A simple example public class HelloWorldApp { public static void main(String[] args) { //Display the string. System.out.println("Hello.
Data Types Modifiers Base data type Size Sign signed int 2 B unsigned float 4 B short double 8 B long char 1 B.
Seven Segment Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 5: Introduction 7Segment Configuration.
اسامي شناسه ها (Identifier names) اسامي متغيرها ، توابع ، برچسب ها (labels) وبقيه اشياء تعريف شده توسط كاربر در C ، شناسه ( identifier ) ناميده مي شود.
 Templates enable us to define generic classes and functions and thus provides support for generic programming. Generic types are used as parameters.
شرط و تصميم اصول كامپيوتر 1. 2 الگوريتم اقليدس E1: [find remainder] Divide m by n and let r be the remainder. Clearly, 0
CSCI 62 Data Structures Dr. Joshua Stough December 2, 2008.
CMSC 341 Lecture 2. Announcements Tutors wanted Office hrs Project 1.
AL-HUSEEN BIN TALAL UNIVERSITY College of Engineering Department of Computer Engineering Object-Oriented Programming Course No.: Fall 2014 Templates.
Chapter 5 The MFC Collection Classes. How to store many data? 1. Use an Array 2. Use a Linked List value: 10 Node * p a a value: 20 Node * p value: 30.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
کلاس های متغيرها در C 1- کلاس متغيرهای اتوماتيک auto int x = 10; /* x is global auto int x = 10; /* x is global void main( ) { void main( ) { int x = 25;
الف) تابع y = f(x) = X >= 0x -2 < x < 0 x3x3 X
به نام خدا.
[c.
تهیه و تنظیم: فاطمه قاسمی دانشگاه صنعتی شریف – پاییز 86
تهیه و تنظیم: فاطمه قاسمی دانشگاه صنعتی شریف – پاییز 86
Evolution of programming languages
تمرین هفتم بسم الله الرحمن الرحیم درس یادگیری ماشین محمدعلی کیوان راد
Data Types.
انواع دستور در برنامه نويسی
بنام خدا زبان برنامه نویسی C (21814( Lecture 12 Selected Topics
آرايه ها.
Odd-even merge sort مرتب سازی.
نمايش اعداد در کامپيوتر چهار عمل اصلي
آشنایی با پایگاه داده mysql
مدارهای منطقی فصل سوم - خصوصیات توابع سويیچی
Introduction to Programming
تهیه و تنظیم: فاطمه قاسمی دانشگاه صنعتی شریف – پاییز 86
ASP.NET فرناز شریعت.
بنام خدا زبان برنامه نویسی C (21814( Lecture 3 Chapter 4
مثال : فلوچارتي رسم كنيد كه دو عدد از ورودي دريافت كرده بزرگترين عدد
Dynamic Memory A whole heap of fun….
The Stack.
Presentation transcript:

دسته بندی زبانها بر حسب نوع زبانهای با نوع : (ايستا : ترجمه) – (پويا : تفسير) تفسيری : Snobol، Apl، Awk، Javascript var kate=“hi” var sam=200 val l=10.25 var j=l sam=kate+sam var ans=l+sam+j kate=ans change type زبانهای بدون نوع (typeless) : عدم ذخيره اطلاعات برای نوع : BCPL V!0,V!1,…V!25 : تخصيص متغير برداری با 26 کلمه ماشين LET F(A,B)=A<B  A,B procedure F(43,21) F:=0 no longer function اسمبلی ؟

- زبانها با وارسی نوع قوی - زبانها با وارسی نوع ضعيف تمرين : Ada و JAVA و prolog (قوی يا ضعيف)؟

هم ارزی متغيرها(equvalency) هم ارزی دو متغير : انتساب به يکديگر؟ - اسمی(name equivalence) : نام نوع يکسان - ساختاری(structure equivalence) : ساختار يکسان اسمی (نام نوع : s) struct s{int a; float b;}; s s1,s2; s1=s2; ساختاری :(نوع : sوss) struct s{int a; float b;}; s s1; (type : s) struct ss{int a; float b;}; ss s2; (type:ss) s1=s2;?

مثال ها class c1{int x;int y;} class c2{int x;int y;} c1 z=new c2(); ? name structure struct {int a;int b;}s1; struct {int a;int b;}s3; void v(s1 ss){…} main(){ s3 s2; v(s2);} name structure

void v(int a1[]){ cout <<a1[5];} main(){ int a3[10]; for(int i=0; i<10;i++)a3[i]=i; v(a3);} name typedef int k1; typedef int k2; k1 s1; k2 s2; s1=s2; name structure C : (struct و class : اسمی) بقيه : ساختاری

پاسکال type personid=array[1..10] of char; vehicleid=array[1..10]of char; procedure vehicle(v1:vehicleid); begin……..end; var p1:personid; begin vehicle(p1); type mismatch end.

پاسکال Type personid=set of char; vehicleid=set of char; procedure vehicle(v1:vehicle); begin…….end; p1:personid; begin vehicle(p1); OK(set : structure) end.

personid=record a:set of char; end; vehicleid=record a:set of char; end; procedure vehicle(v1:vehicleid); begin…..end; var p:personid; begin vehicle(p); type mismatch(record:name) end;

زبانهای Ada – modoula-3 – Java ؟

نوع های عمومی(generic) نوع قابل تغيير. int n=2; int* m=&n; float f; float* n=&f; m=n; ارجاع عمومی: m=(int*)n; int n=2; float f=3.5; void* x; x=&n; x=&f; int* z1=&n; float* z2=&f; z1=x; z2=x; *x=3; *(int*)x=3;

template class array{ T a[100]; public: T& operator[] (int index){ if (index>=0 && index<size) return a[index];} }; main(){ array ia; array fa; for(int i=0; i<20; i++){ia[i]=i*i; fa[i]=float(i)*1.4; }

توابع template نوشتن توابع عمومی بجای توابع خاص مثال : تابعی بنويسيد که ماکزيمم دو عدد را برگرداند. برای اعداد صحيح : int max(int k, int j) { if k<j return j; else return k;} برای اعداد اعشاری : float max(float k, float j){if k<j return j;else return k;}

template T min (T x, T y) { return (x < y) ? x : y; } void main ( ) { int k =2, kk = 3; float z = 1.2, zz = 1.3; cout << min(k,kk); cout << min(z,zz); }

مثال : اشکال در عدم استفاده از template int min(int k, int j) { return(k<j) ? k : j; } void main( ) { float k = 2.5, kk = 2.4; cout <<min(k,kk); }

JAVA import java.util.* Stack my_stack=new Stack(); String s=“Hi Ali”; foo f=new foo(); my_stack.push(s); my_stack.push(f); s=(String)my_stack.pop();

Ada generic type ITEM is private; procedure EXCHANGE(X,Y:in out ITEM)is T:ITEM; begin T:=X; X:=Y; Y:=T; end; procedure swap is new EXCHANGE(REAL); procedure swap is new EXCHANGE(INTEGER );

generic MAX:POSITIVE; type ITEM is private; package stack is procedure PUSH(X:ITEM); function POP return ITEM; end STACK; package BODY STACK is S:array(1..MAX) of ITEM; TOP:INTEGER range 0..MAX; end STACK; declare package MY_STACK is new STACK(100,REAL); use MY_STACK; begin push(X); Y:=pop; end;