|
package fundamemtos |
|
|
|
import "core:fmt" |
|
|
|
main :: proc(){ |
|
fmt.println("\t[ Fundamentos de Odin Lang]"); |
|
testA(); |
|
testB(); |
|
testC(); |
|
testD(); |
|
} |
|
|
|
sueldo_calculado :: proc(s: f32) -> f32{ |
|
return s + (s*0.15); |
|
} |
|
|
|
testD :: proc(){ |
|
CONSTANT_BOOLEAN :: true |
|
|
|
if CONSTANT_BOOLEAN { |
|
fmt.printfln("%.2f", 3.1416); |
|
} |
|
|
|
opera_booleana: bool = 45 > 200; |
|
if opera_booleana { |
|
fmt.println(" Bad "); |
|
}else{ |
|
fmt.println(" Good 😃"); |
|
} |
|
|
|
if !opera_booleana{ |
|
fmt.println(" Good 😃"); |
|
} |
|
|
|
sueldo_base:f32 = 25000.0; |
|
sueldo_final:f32 = sueldo_base; |
|
|
|
if sueldo_base < 30000.0 && sueldo_base >= 22000.0{ |
|
sueldo_final = sueldo_calculado(sueldo_base); |
|
} |
|
|
|
fmt.printfln("Sueldo base: $%.1f", sueldo_base); |
|
aumento:f32 = sueldo_final-sueldo_base; |
|
fmt.printfln("Sueldo final: $%.1f", sueldo_final); |
|
fmt.printfln("El aumento fue de: $%.1f", aumento); |
|
|
|
} |
|
|
|
|
|
testC :: proc(){ |
|
variable_f32: f32 = 5.43; |
|
variable_bool:b32 = 23 > 3; |
|
fmt.printfln("%.1f", variable_f32) |
|
fmt.println(typeid_of(type_of(variable_f32))) // f32 |
|
fmt.println("Es verdadero?:", variable_bool) |
|
fmt.println(typeid_of(type_of(variable_bool))) // b32 |
|
} |
|
|
|
testB :: proc(){ |
|
program := "+ + * 😃 - /" |
|
accumulator := 0 |
|
|
|
for token in program { |
|
switch token { |
|
case '+': accumulator += 1 |
|
case '-': accumulator -= 1 |
|
case '*': accumulator *= 2 |
|
case '/': accumulator /= 2 |
|
case '😃': accumulator *= accumulator |
|
case: // Ignore everything else |
|
} |
|
} |
|
|
|
fmt.printf("El programa \"%s\" calculo el valor %d\n", |
|
program, accumulator) |
|
} |
|
|
|
testA :: proc(){ |
|
CONSTANT_NUMBER :: 12 |
|
DECIMAL_NUMBER :: 6.43 |
|
|
|
fmt.println("\t[ Variables y tipos de datos en Odin Lang]"); |
|
num_integer: int = 23; |
|
fmt.println("No. entero: ", num_integer); |
|
otro_num_integer:= 43; |
|
fmt.println("Otro no. entero: ", otro_num_integer); |
|
otro_num_integer = 21; |
|
fmt.println("Otro no. entero: ", otro_num_integer); |
|
float_number:f32 = 5.4; |
|
fmt.println("No. flotante: ", float_number); |
|
float_number = 0.433; |
|
fmt.println("No. flotante: ", float_number); |
|
fmt.println("Constante entera: ", CONSTANT_NUMBER); |
|
fmt.println("Constante decimal: ", DECIMAL_NUMBER); |
|
isCorrect: bool = true; |
|
fmt.println("Booleano: ", isCorrect); |
|
some_variable := 'A'; |
|
fmt.println("Rune: ", some_variable); |
|
// cadena: string = "FERROCARRIL" |
|
cadena := "FERROCARRIL"; |
|
fmt.println("String: ", cadena); |
|
} |