diff --git a/functions/core/all_slice.go b/functions/core/all_slice.go new file mode 100644 index 00000000..08c82c63 --- /dev/null +++ b/functions/core/all_slice.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// All devuelve true si todos los elementos del slice cumplen el predicado. +func All[T any](slice []T, predicate func(T) bool) bool { + // stub + return false +} diff --git a/functions/core/all_slice.md b/functions/core/all_slice.md new file mode 100644 index 00000000..90d9b3dc --- /dev/null +++ b/functions/core/all_slice.md @@ -0,0 +1,32 @@ +--- +name: all_slice +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func All[T any](slice []T, predicate func(T) bool) bool" +description: "Devuelve true si todos los elementos del slice cumplen el predicado." +tags: [slice, functional, generic, predicate] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/all_slice.go" +--- + +## Ejemplo + +```go +result := All([]int{2, 4, 6}, func(x int) bool { return x%2 == 0 }) +// result = true +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/any_slice.go b/functions/core/any_slice.go new file mode 100644 index 00000000..8aadde79 --- /dev/null +++ b/functions/core/any_slice.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Any devuelve true si al menos un elemento del slice cumple el predicado. +func Any[T any](slice []T, predicate func(T) bool) bool { + // stub + return false +} diff --git a/functions/core/any_slice.md b/functions/core/any_slice.md new file mode 100644 index 00000000..99edcf93 --- /dev/null +++ b/functions/core/any_slice.md @@ -0,0 +1,32 @@ +--- +name: any_slice +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Any[T any](slice []T, predicate func(T) bool) bool" +description: "Devuelve true si al menos un elemento del slice cumple el predicado." +tags: [slice, functional, generic, predicate] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/any_slice.go" +--- + +## Ejemplo + +```go +result := Any([]int{1, 2, 3}, func(x int) bool { return x > 2 }) +// result = true +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/compose2.go b/functions/core/compose2.go new file mode 100644 index 00000000..3d77abc0 --- /dev/null +++ b/functions/core/compose2.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Compose2 compone dos funciones de derecha a izquierda. +func Compose2[A, B, C any](f2 func(B) C, f1 func(A) B) func(A) C { + // stub + return nil +} diff --git a/functions/core/compose2.md b/functions/core/compose2.md new file mode 100644 index 00000000..9fabdbd9 --- /dev/null +++ b/functions/core/compose2.md @@ -0,0 +1,34 @@ +--- +name: compose2 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Compose2[A, B, C any](f2 func(B) C, f1 func(A) B) func(A) C" +description: "Compone dos funciones de derecha a izquierda. compose2(g, f)(x) = g(f(x))." +tags: [functional, composition, generic] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/compose2.go" +--- + +## Ejemplo + +```go +double := func(x int) int { return x * 2 } +toString := func(x int) string { return fmt.Sprintf("%d", x) } +doubleStr := Compose2(toString, double) +result := doubleStr(5) // "10" +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/const_func.go b/functions/core/const_func.go new file mode 100644 index 00000000..7109e049 --- /dev/null +++ b/functions/core/const_func.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Const devuelve una funcion que siempre retorna el valor dado, ignorando su argumento. +func Const[T, U any](value T) func(U) T { + // stub + return nil +} diff --git a/functions/core/const_func.md b/functions/core/const_func.md new file mode 100644 index 00000000..420fa9c6 --- /dev/null +++ b/functions/core/const_func.md @@ -0,0 +1,32 @@ +--- +name: const_func +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Const[T, U any](value T) func(U) T" +description: "Devuelve una funcion que siempre retorna el valor dado, ignorando su argumento." +tags: [functional, generic, const] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/const_func.go" +--- + +## Ejemplo + +```go +always42 := Const[int, string](42) +result := always42("ignored") // 42 +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/curry2.go b/functions/core/curry2.go new file mode 100644 index 00000000..90b4eddb --- /dev/null +++ b/functions/core/curry2.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Curry2 transforma una funcion de dos argumentos en forma currificada. +func Curry2[A, B, C any](f func(A, B) C) func(A) func(B) C { + // stub + return nil +} diff --git a/functions/core/curry2.md b/functions/core/curry2.md new file mode 100644 index 00000000..ce05416a --- /dev/null +++ b/functions/core/curry2.md @@ -0,0 +1,34 @@ +--- +name: curry2 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Curry2[A, B, C any](f func(A, B) C) func(A) func(B) C" +description: "Transforma una funcion de dos argumentos en forma currificada." +tags: [functional, generic, curry] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/curry2.go" +--- + +## Ejemplo + +```go +add := func(a, b int) int { return a + b } +curriedAdd := Curry2(add) +add5 := curriedAdd(5) +result := add5(3) // 8 +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/drop.go b/functions/core/drop.go new file mode 100644 index 00000000..54fddce0 --- /dev/null +++ b/functions/core/drop.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Drop elimina los primeros n elementos de un slice y devuelve el resto. +func Drop[T any](slice []T, n int) []T { + // stub + return nil +} diff --git a/functions/core/drop.md b/functions/core/drop.md new file mode 100644 index 00000000..63e80b79 --- /dev/null +++ b/functions/core/drop.md @@ -0,0 +1,32 @@ +--- +name: drop +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Drop[T any](slice []T, n int) []T" +description: "Elimina los primeros n elementos de un slice y devuelve el resto." +tags: [slice, functional, generic] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/drop.go" +--- + +## Ejemplo + +```go +result := Drop([]int{1, 2, 3, 4, 5}, 2) +// result = [3, 4, 5] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/find.go b/functions/core/find.go new file mode 100644 index 00000000..db536b7a --- /dev/null +++ b/functions/core/find.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Find devuelve el primer elemento del slice que cumple el predicado, envuelto en Option. +func Find[T any](slice []T, predicate func(T) bool) Option[T] { + // stub + return Option[T]{} +} diff --git a/functions/core/find.md b/functions/core/find.md new file mode 100644 index 00000000..a6add199 --- /dev/null +++ b/functions/core/find.md @@ -0,0 +1,33 @@ +--- +name: find +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Find[T any](slice []T, predicate func(T) bool) Option[T]" +description: "Devuelve el primer elemento del slice que cumple el predicado, envuelto en Option." +tags: [slice, functional, generic, search] +uses_functions: [] +uses_types: [option_go_core] +returns: [option_go_core] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/find.go" +--- + +## Ejemplo + +```go +nums := []int{1, 2, 3, 4, 5} +result := Find(nums, func(n int) bool { return n > 3 }) +// result es Some(4) +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/find_index.go b/functions/core/find_index.go new file mode 100644 index 00000000..fa12ce4b --- /dev/null +++ b/functions/core/find_index.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// FindIndex devuelve el indice del primer elemento que cumple el predicado. +func FindIndex[T any](slice []T, predicate func(T) bool) Option[int] { + // stub + return Option[int]{} +} diff --git a/functions/core/find_index.md b/functions/core/find_index.md new file mode 100644 index 00000000..c30b4156 --- /dev/null +++ b/functions/core/find_index.md @@ -0,0 +1,32 @@ +--- +name: find_index +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func FindIndex[T any](slice []T, predicate func(T) bool) Option[int]" +description: "Devuelve el indice del primer elemento que cumple el predicado, envuelto en Option." +tags: [slice, functional, generic, search] +uses_functions: [] +uses_types: [option_go_core] +returns: [option_go_core] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/find_index.go" +--- + +## Ejemplo + +```go +idx := FindIndex([]int{10, 20, 30}, func(x int) bool { return x > 15 }) +// idx = Some(1) +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/flat_map_slice.go b/functions/core/flat_map_slice.go new file mode 100644 index 00000000..dfd1c376 --- /dev/null +++ b/functions/core/flat_map_slice.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// FlatMapSlice aplica una funcion que devuelve slices a cada elemento y aplana el resultado. +func FlatMapSlice[T, U any](slice []T, f func(T) []U) []U { + // stub + return nil +} diff --git a/functions/core/flat_map_slice.md b/functions/core/flat_map_slice.md new file mode 100644 index 00000000..1fb2a388 --- /dev/null +++ b/functions/core/flat_map_slice.md @@ -0,0 +1,32 @@ +--- +name: flat_map_slice +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func FlatMapSlice[T, U any](slice []T, f func(T) []U) []U" +description: "Aplica una funcion que devuelve slices a cada elemento y aplana el resultado." +tags: [slice, functional, generic, flatmap] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/flat_map_slice.go" +--- + +## Ejemplo + +```go +result := FlatMapSlice([]int{1, 2, 3}, func(x int) []int { return []int{x, x * 10} }) +// result = [1, 10, 2, 20, 3, 30] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/flatten.go b/functions/core/flatten.go new file mode 100644 index 00000000..9b77161b --- /dev/null +++ b/functions/core/flatten.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Flatten aplana un slice de slices en un unico slice. +func Flatten[T any](slices [][]T) []T { + // stub + return nil +} diff --git a/functions/core/flatten.md b/functions/core/flatten.md new file mode 100644 index 00000000..56542cee --- /dev/null +++ b/functions/core/flatten.md @@ -0,0 +1,32 @@ +--- +name: flatten +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Flatten[T any](slices [][]T) []T" +description: "Aplana un slice de slices en un unico slice." +tags: [slice, functional, generic] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/flatten.go" +--- + +## Ejemplo + +```go +result := Flatten([][]int{{1, 2}, {3, 4}, {5}}) +// result = [1, 2, 3, 4, 5] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/flip.go b/functions/core/flip.go new file mode 100644 index 00000000..d77c0a8e --- /dev/null +++ b/functions/core/flip.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Flip intercambia el orden de los argumentos de una funcion de dos parametros. +func Flip[A, B, C any](f func(A, B) C) func(B, A) C { + // stub + return nil +} diff --git a/functions/core/flip.md b/functions/core/flip.md new file mode 100644 index 00000000..e06f04d1 --- /dev/null +++ b/functions/core/flip.md @@ -0,0 +1,33 @@ +--- +name: flip +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Flip[A, B, C any](f func(A, B) C) func(B, A) C" +description: "Intercambia el orden de los argumentos de una funcion de dos parametros." +tags: [functional, generic] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/flip.go" +--- + +## Ejemplo + +```go +sub := func(a, b int) int { return a - b } +flipped := Flip(sub) +result := flipped(3, 10) // 7 (10 - 3) +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/group_by.go b/functions/core/group_by.go new file mode 100644 index 00000000..82677e71 --- /dev/null +++ b/functions/core/group_by.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// GroupBy agrupa elementos de un slice por clave generada con una funcion. +func GroupBy[T any, K comparable](slice []T, keyFn func(T) K) map[K][]T { + // stub + return nil +} diff --git a/functions/core/group_by.md b/functions/core/group_by.md new file mode 100644 index 00000000..dabf6a5a --- /dev/null +++ b/functions/core/group_by.md @@ -0,0 +1,32 @@ +--- +name: group_by +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func GroupBy[T any, K comparable](slice []T, keyFn func(T) K) map[K][]T" +description: "Agrupa elementos de un slice por clave generada con una funcion." +tags: [slice, functional, generic, grouping] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/group_by.go" +--- + +## Ejemplo + +```go +groups := GroupBy([]string{"go", "git", "python"}, func(s string) byte { return s[0] }) +// groups = map[byte][]string{'g': {"go", "git"}, 'p': {"python"}} +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/identity.go b/functions/core/identity.go new file mode 100644 index 00000000..1141c3a5 --- /dev/null +++ b/functions/core/identity.go @@ -0,0 +1,10 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Identity devuelve el valor recibido sin modificarlo. +func Identity[T any](x T) T { + // stub + var zero T + return zero +} diff --git a/functions/core/identity.md b/functions/core/identity.md new file mode 100644 index 00000000..fccbcae2 --- /dev/null +++ b/functions/core/identity.md @@ -0,0 +1,32 @@ +--- +name: identity +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Identity[T any](x T) T" +description: "Devuelve el valor recibido sin modificarlo. Elemento neutro de la composicion." +tags: [functional, generic, identity] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/identity.go" +--- + +## Ejemplo + +```go +x := Identity(42) // 42 +s := Identity("abc") // "abc" +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/partial2.go b/functions/core/partial2.go new file mode 100644 index 00000000..15cfe7d4 --- /dev/null +++ b/functions/core/partial2.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Partial2 aplica parcialmente el primer argumento de una funcion de dos parametros. +func Partial2[A, B, C any](f func(A, B) C, a A) func(B) C { + // stub + return nil +} diff --git a/functions/core/partial2.md b/functions/core/partial2.md new file mode 100644 index 00000000..9028b891 --- /dev/null +++ b/functions/core/partial2.md @@ -0,0 +1,33 @@ +--- +name: partial2 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Partial2[A, B, C any](f func(A, B) C, a A) func(B) C" +description: "Aplica parcialmente el primer argumento de una funcion de dos parametros." +tags: [functional, generic, partial] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/partial2.go" +--- + +## Ejemplo + +```go +mul := func(a, b int) int { return a * b } +double := Partial2(mul, 2) +result := double(5) // 10 +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/pipe2.go b/functions/core/pipe2.go new file mode 100644 index 00000000..d0609053 --- /dev/null +++ b/functions/core/pipe2.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Pipe2 compone dos funciones de izquierda a derecha. +func Pipe2[A, B, C any](f1 func(A) B, f2 func(B) C) func(A) C { + // stub + return nil +} diff --git a/functions/core/pipe2.md b/functions/core/pipe2.md new file mode 100644 index 00000000..a693ae0b --- /dev/null +++ b/functions/core/pipe2.md @@ -0,0 +1,34 @@ +--- +name: pipe2 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Pipe2[A, B, C any](f1 func(A) B, f2 func(B) C) func(A) C" +description: "Compone dos funciones de izquierda a derecha. pipe2(f, g)(x) = g(f(x))." +tags: [functional, composition, generic, pipe] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/pipe2.go" +--- + +## Ejemplo + +```go +double := func(x int) int { return x * 2 } +toString := func(x int) string { return fmt.Sprintf("%d", x) } +doubleStr := Pipe2(double, toString) +result := doubleStr(5) // "10" +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/pipe3.go b/functions/core/pipe3.go new file mode 100644 index 00000000..a42eec0c --- /dev/null +++ b/functions/core/pipe3.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Pipe3 compone tres funciones de izquierda a derecha. +func Pipe3[A, B, C, D any](f1 func(A) B, f2 func(B) C, f3 func(C) D) func(A) D { + // stub + return nil +} diff --git a/functions/core/pipe3.md b/functions/core/pipe3.md new file mode 100644 index 00000000..957b62d2 --- /dev/null +++ b/functions/core/pipe3.md @@ -0,0 +1,35 @@ +--- +name: pipe3 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Pipe3[A, B, C, D any](f1 func(A) B, f2 func(B) C, f3 func(C) D) func(A) D" +description: "Compone tres funciones de izquierda a derecha." +tags: [functional, composition, generic, pipe] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/pipe3.go" +--- + +## Ejemplo + +```go +add1 := func(x int) int { return x + 1 } +double := func(x int) int { return x * 2 } +toString := func(x int) string { return fmt.Sprintf("%d", x) } +pipeline := Pipe3(add1, double, toString) +result := pipeline(3) // "8" +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/reduce.go b/functions/core/reduce.go new file mode 100644 index 00000000..d81ac703 --- /dev/null +++ b/functions/core/reduce.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Reduce reduce un slice a un unico valor aplicando una funcion acumuladora. +func Reduce[T, U any](slice []T, initial U, f func(U, T) U) U { + // stub + return initial +} diff --git a/functions/core/reduce.md b/functions/core/reduce.md new file mode 100644 index 00000000..ec70f7b1 --- /dev/null +++ b/functions/core/reduce.md @@ -0,0 +1,32 @@ +--- +name: reduce +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Reduce[T, U any](slice []T, initial U, f func(U, T) U) U" +description: "Reduce un slice a un unico valor aplicando una funcion acumuladora de izquierda a derecha." +tags: [slice, functional, generic, fold] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/reduce.go" +--- + +## Ejemplo + +```go +sum := Reduce([]int{1, 2, 3, 4}, 0, func(acc, x int) int { return acc + x }) +// sum = 10 +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/take.go b/functions/core/take.go new file mode 100644 index 00000000..50f20e51 --- /dev/null +++ b/functions/core/take.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Take devuelve los primeros n elementos de un slice. +func Take[T any](slice []T, n int) []T { + // stub + return nil +} diff --git a/functions/core/take.md b/functions/core/take.md new file mode 100644 index 00000000..d69c101e --- /dev/null +++ b/functions/core/take.md @@ -0,0 +1,32 @@ +--- +name: take +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Take[T any](slice []T, n int) []T" +description: "Devuelve los primeros n elementos de un slice." +tags: [slice, functional, generic] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/take.go" +--- + +## Ejemplo + +```go +result := Take([]int{1, 2, 3, 4, 5}, 3) +// result = [1, 2, 3] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/uncurry2.go b/functions/core/uncurry2.go new file mode 100644 index 00000000..f7488abd --- /dev/null +++ b/functions/core/uncurry2.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Uncurry2 transforma una funcion currificada en una funcion normal de dos argumentos. +func Uncurry2[A, B, C any](f func(A) func(B) C) func(A, B) C { + // stub + return nil +} diff --git a/functions/core/uncurry2.md b/functions/core/uncurry2.md new file mode 100644 index 00000000..bc0e04ad --- /dev/null +++ b/functions/core/uncurry2.md @@ -0,0 +1,35 @@ +--- +name: uncurry2 +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Uncurry2[A, B, C any](f func(A) func(B) C) func(A, B) C" +description: "Transforma una funcion currificada en una funcion normal de dos argumentos." +tags: [functional, generic, curry] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/uncurry2.go" +--- + +## Ejemplo + +```go +curriedAdd := func(a int) func(int) int { + return func(b int) int { return a + b } +} +add := Uncurry2(curriedAdd) +result := add(3, 5) // 8 +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/unique.go b/functions/core/unique.go new file mode 100644 index 00000000..c717dfa4 --- /dev/null +++ b/functions/core/unique.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Unique devuelve un slice con elementos unicos preservando el orden original. +func Unique[T comparable](slice []T) []T { + // stub + return nil +} diff --git a/functions/core/unique.md b/functions/core/unique.md new file mode 100644 index 00000000..a16d0e74 --- /dev/null +++ b/functions/core/unique.md @@ -0,0 +1,32 @@ +--- +name: unique +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Unique[T comparable](slice []T) []T" +description: "Devuelve un slice con elementos unicos preservando el orden original." +tags: [slice, functional, generic, dedup] +uses_functions: [] +uses_types: [] +returns: [] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/unique.go" +--- + +## Ejemplo + +```go +result := Unique([]int{1, 2, 2, 3, 1, 4}) +// result = [1, 2, 3, 4] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core. diff --git a/functions/core/zip.go b/functions/core/zip.go new file mode 100644 index 00000000..12d053dd --- /dev/null +++ b/functions/core/zip.go @@ -0,0 +1,9 @@ +package core + +// Implementation: github.com/lucasdataproyects/devfactory/core + +// Zip combina dos slices en un slice de pares elemento a elemento. +func Zip[T, U any](a []T, b []U) []Pair[T, U] { + // stub + return nil +} diff --git a/functions/core/zip.md b/functions/core/zip.md new file mode 100644 index 00000000..3c0a3fa0 --- /dev/null +++ b/functions/core/zip.md @@ -0,0 +1,32 @@ +--- +name: zip +kind: function +lang: go +domain: core +version: "1.0.0" +purity: pure +signature: "func Zip[T, U any](a []T, b []U) []Pair[T, U]" +description: "Combina dos slices en un slice de pares elemento a elemento." +tags: [slice, functional, generic, pair] +uses_functions: [] +uses_types: [pair_go_core] +returns: [pair_go_core] +returns_optional: false +error_type: "" +imports: [] +tested: false +tests: [] +test_file_path: "" +file_path: "functions/core/zip.go" +--- + +## Ejemplo + +```go +pairs := Zip([]string{"a", "b"}, []int{1, 2}) +// pairs = [{a 1}, {b 2}] +``` + +## Notas + +Funcion pura generica. Implementacion en devfactory/core.