Las funciones permiten agrupar código con un propósito determinado y reutilizarlo invocándolo desde diferentes partes de un programa. Este documento explica la sintaxis básica para definir funciones en JavaScript, incluyendo parámetros, cuerpo y retorno. También cubre conceptos como el ámbito de las variables, la pila de llamadas y cómo invocar funciones. Se proveen ejemplos de funciones para calcular el mcd, factoriales y comprobar si un número es primo.
New language from Google, static safe compiler, with GC and as fast as C++ or Java, syntax simpler then Python - 2 hour-long tutorial and you can start code.
In this talk Serhii will talk about Go, also known as Golang – an open source language developed at Google and used in production by companies such as Docker, Dropbox, Facebook and Google itself. Go is now heavily used as a general-purpose programming language that’s a pleasure to use and maintain. This introductory talk contains many live demos of basic language concepts, concurrency model, simple HTTP-based endpoint implementation and, of course, tests using build-in framework. This presentation will be interesting for backend engineers and DevOps to understand why Go had become so popular and how it might help to build robust and maintanable services.
Agenda of the presentation:
1. Go is not C, not Java, not anything
2. Rob Pike argument
3. Main ideas and basics
4. Concurrency model
5. Tools
6. Issues
New language from Google, static safe compiler, with GC and as fast as C++ or Java, syntax simpler then Python - 2 hour-long tutorial and you can start code.
In this talk Serhii will talk about Go, also known as Golang – an open source language developed at Google and used in production by companies such as Docker, Dropbox, Facebook and Google itself. Go is now heavily used as a general-purpose programming language that’s a pleasure to use and maintain. This introductory talk contains many live demos of basic language concepts, concurrency model, simple HTTP-based endpoint implementation and, of course, tests using build-in framework. This presentation will be interesting for backend engineers and DevOps to understand why Go had become so popular and how it might help to build robust and maintanable services.
Agenda of the presentation:
1. Go is not C, not Java, not anything
2. Rob Pike argument
3. Main ideas and basics
4. Concurrency model
5. Tools
6. Issues
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
The slides from the talk I gave at Oracle III #JuevesTecnológicos in Madrid.
A review of how the ParallelStreams Work in Java 8 and some considerations we must know in order to get the better performance from the concurrent data processing in #Java8
Mockito vs JMockit, battle of the mocking frameworksEndranNL
(Original keynote slides can be found at https://github.com/Endran/PublicSlides)
For years the industry standard of mocking on the JVM has been Mockito. Mockito is a wonderful library that really speeds up your testing by allowing you to create mocks in a very simple way. That being said, it does have its drawbacks, for which different strategies need to be deployed to keep your code testable. The main drawbacks are statics and finals. Final classes cannot be mocked, nor final methods, and also static methods are a no-go. To work with these type of things we need to wrap it, and copy the signature in a non final, non static way.
I have a great adversity against statics, I've devoted an entire post about it, in short; It hides dependencies and brings so little convenience at the costs of its drawbacks. Finals on the other hand have purpose, it helps messaging the goal of a class or method. Java is one of the few languages where classes and methods are open/virtual by default and have to be closed/final by explicit action. In (for example) Kotlin, everything is final by default, if you do not want something to be final, you should use the open keyword.
No matter if you follow the principle of making things final, static or not, if you are using Mockito the decision has been made. This mocking framework demands that everything is non-final, demands that everything is designed to be extended, since it might need to be mocked away. We should be able to improve upon this, and by the name of this post, you should be able to guess which framework will save the day. JMockit will help us with our impediments, and will give some other nifty benefits as well!
Asynchronous JavaScript Programming with Callbacks & PromisesHùng Nguyễn Huy
This presentation is about JavaScript Promise. Topics covered in this session are:
1. Asynchronous processing in JavaScript
2. Callbacks and Callback hell
3. Promises arrive in JavaScript!
4. Constructing a Promise
5. Promise states
6. Promises chaining and transformation
7. Error handling
8. Promise.all() and Promise.race()
The slides from the talk I gave at Oracle III #JuevesTecnológicos in Madrid.
A review of how the ParallelStreams Work in Java 8 and some considerations we must know in order to get the better performance from the concurrent data processing in #Java8
Mockito vs JMockit, battle of the mocking frameworksEndranNL
(Original keynote slides can be found at https://github.com/Endran/PublicSlides)
For years the industry standard of mocking on the JVM has been Mockito. Mockito is a wonderful library that really speeds up your testing by allowing you to create mocks in a very simple way. That being said, it does have its drawbacks, for which different strategies need to be deployed to keep your code testable. The main drawbacks are statics and finals. Final classes cannot be mocked, nor final methods, and also static methods are a no-go. To work with these type of things we need to wrap it, and copy the signature in a non final, non static way.
I have a great adversity against statics, I've devoted an entire post about it, in short; It hides dependencies and brings so little convenience at the costs of its drawbacks. Finals on the other hand have purpose, it helps messaging the goal of a class or method. Java is one of the few languages where classes and methods are open/virtual by default and have to be closed/final by explicit action. In (for example) Kotlin, everything is final by default, if you do not want something to be final, you should use the open keyword.
No matter if you follow the principle of making things final, static or not, if you are using Mockito the decision has been made. This mocking framework demands that everything is non-final, demands that everything is designed to be extended, since it might need to be mocked away. We should be able to improve upon this, and by the name of this post, you should be able to guess which framework will save the day. JMockit will help us with our impediments, and will give some other nifty benefits as well!
Html 5: elementos para mejorar la apariencijcremiro
HTML 5 incorpora nuevos elementos para describir el contenido de una forma más precisa, así como, redefine la función de otros ya presentes en versiones anteriores.
Conceptos básicos sobre funciones en C: que son, para qué sirven, cómo declararlas, cómo implementarlas, cómo pasar parámetros tanto por valor como por referencia, etc
Las transparencias sobre operadores aritméticos son una herramienta visual esencial para comprender cómo funcionan las operaciones matemáticas fundamentales en programación y matemáticas.
ROMPECABEZAS DE ECUACIONES DE PRIMER GRADO OLIMPIADA DE PARÍS 2024. Por JAVIE...JAVIER SOLIS NOYOLA
El Mtro. JAVIER SOLIS NOYOLA crea y desarrolla el “ROMPECABEZAS DE ECUACIONES DE 1ER. GRADO OLIMPIADA DE PARÍS 2024”. Esta actividad de aprendizaje propone retos de cálculo algebraico mediante ecuaciones de 1er. grado, y viso-espacialidad, lo cual dará la oportunidad de formar un rompecabezas. La intención didáctica de esta actividad de aprendizaje es, promover los pensamientos lógicos (convergente) y creativo (divergente o lateral), mediante modelos mentales de: atención, memoria, imaginación, percepción (Geométrica y conceptual), perspicacia, inferencia, viso-espacialidad. Esta actividad de aprendizaje es de enfoques lúdico y transversal, ya que integra diversas áreas del conocimiento, entre ellas: matemático, artístico, lenguaje, historia, y las neurociencias.
Las capacidades sociomotrices son las que hacen posible que el individuo se pueda desenvolver socialmente de acuerdo a la actuación motriz propias de cada edad evolutiva del individuo; Martha Castañer las clasifica en: Interacción y comunicación, introyección, emoción y expresión, creatividad e imaginación.
2. Funciones definidas por el usuario
• JavaScript contiene funciones ya construidas
(alert, prompt ).
• JavaScript permite definir funciones e
invocarlas posteriormente.
• Una función agrupa normalmente código que
se ejecuta con un fin determinado.
3. Definición de funciones
• La definición de una función comienza con la
palabra reservada function
• A continuación, un identificador y entre
paréntesis los parámetros que admite la
función.
• El cuerpo de la función estará delimitado por
llaves.
• La palabra reservada return para devolver un
valor.
4. Ejemplo: declaración de una función
function valor_absoluto (numero){
if (numero < 0){
numero = - numero;
}
return numero
}
Nombre de la función
Parámetro
Cuerpo de la función
function nombre_de_la_función (lista_de_parámetros){
lista_de_instrucciones
}
Sintaxis
5. Invocación de funciones
• Una función puede ser invocada en cualquier
lugar de un documento HTML donde se pueda
incluir código JavaScript.
• Antes de ejecutar ninguna instrucción, el
navegador espera a cargar todas las
definiciones de funciones.
• Es posible invocar una función aún cuando no
se haya producido su carga.
6. Ejemplos: invocación de funciones
function mcd ( x, y){
var resto=0;
while ( x % y != 0 ){
resto= x % y;
x = y;
y = resto;
}
return y;
}
var aux= mcd (34, 12);
// la variable aux tendrá el valor 2
var aux = mcd (15,aux);
// la variable aux tendrá el valor 1
var aux = mcd (25,45) * 4;
// la variable aux tendrá el valor 20
Declaración Invocación
7. Ámbito de las variables
• El ámbito de una variable definida en una
función es el cuerpo de la función.
• Si dentro de una función no se ha definido una
función con el mismo identificador de una
variable que se encuentra fuera de la función,
la variable externa puede utilizarse dentro de
la función.
8. Ejemplo: ámbito de una variable
var x = 0;
var z = 3;
var m = 1;
function abracadabra ( x, y){
var z = 0;
while ( x > y ){
x = x - 1;
y = y + 1;
m = m + 1;
}
return y;
}
Los identificadores se refieren a los
parámetros de la función y a la
variable definida dentro de la
función (z)
Se refiere a la variable local, pues
no se ha definido ninguna variable
local con el mismo identificador.
9. La pila de llamadas
• Cuando se invoca a una función, el control de
la ejecución se transfiere a la función.
• Se almacena el estado el programa, para
posteriormente a la finalización de la función
devolver el control a aquel (desapilando los
valores antes almacenados)
• Este comportamiento permite la recursión.
10. Argumentos
• En la declaración de una función se incluyen
los argumentos con los que se invocará.
• Si se produce la invocación con mas
argumentos de los que hay en la cabecera, los
que sobren se ingnorarán.
• Es posible que una función pueda “capturar”
los argumentos con los que fue invocada.
11. Diseño de funciones
• Las funciones permiten:
– Agrupar código que se repite una y otra vez.
– Crear una función en el sentido matemático
– Recursión
12. Ejemplo I
function mcd ( x, y){
var resto=0;
while ( x % y != 0 ){
resto= x % y;
x = y;
y = resto;
}
return y;
}
Esta función permite calcular el máximo
común divisor de dos números, utilizando el
algoritmo de Euclides
Procedimiento:
Dividimos un número entre otro, si la
división es exacta (el resto es 0), el máximo
común divisor es el divisor, en otro caso (el
resto es distinto de cero), cambiar el
dividendo por el divisor y el divisor por el
dividendo, volver hacer el proceso hasta
que el resto sea cero.
13. Ejemplo II
function factorial (numero){
var resultado = 1;
while (numero != 0){
resultado = resultado * numero;
numero = numero - 1;
}
return resultado;
}
Función iterativa
function factorial (numero){
var resultado = 1;
if (numero == 1){
return 1;
}
else{
return numero*factorial (numero - 1);
}
}
Función recursiva
Cálculo del
factorial de un
número
14. Ejemplo III
function es_primo (numero){
var cota = Math.floor(numero / 2);
var candidato = 2;
var primo = true;
while (primo && candidato <= cota){
if (numero % candidato == 0){
primo = false;
}
candidato = candidato + 1;
}
return primo;
}
Esta función devuelve
verdadero si el número es
primo, y falso en otro caso
15. Ejemplo: invocación de una función
function es_primo (numero){
var cota = Math.floor(numero / 2);
var candidato = 2;
var primo = true;
while (primo && candidato <= cota){
if (numero % candidato == 0){
primo = false;
}
candidato = candidato + 1;
}
return primo;
}
var resultado = '';
for (i=2; i <= 1000; i++){
if (es_primo(i)){
resultado = resultado + ' - ' + i;
}
}
alert(resultado);
Este código invoca a la
función es_primo para
mostrar los números primos
que se encuentran entre 2 y
1.000.