one more case where conv d be awesome,
with
fnUtils.InputParams() ParamSlice
Where
ParamSlice []struct{Name,Type string}
With little help, I can do stuff like
ctxFilter := astutil.FilterParamSlice.ByType(ctxCtx)
fnUtils.InputParams().Filter(ctxFilter).Map(func(p
astutil.Param) astutil.Param {
...
return p
})
that works, but its not the best factorization possible,
let say the language provide a construct
- to make a getter of a type property
- a deep eq func of a type
such as an approximation would be
typeGet := get.(Param.Type) // func() string
strEq := conv(func(left func() string) func(right string) bool,
eq.(string))
ctxFilter := strEq(typeGet)
in short
- make a getter of Param.type => func()string
- convert string.eq from func(s,s) to a string consumer
=> strEq := func(left func() string) func(right string) bool
- create the value eqer, of a value getter,
=> ctxFilter := strEq(typeGet)
then pass it to a stream/array like data structure (to be defined)
the provider can provides struct only,
and the declarer has more ways to handle the declared api.
On Tuesday, May 30, 2017 at 5:14:57 PM UTC+2, [email protected] wrote:
>
> I just realized what d be awesome is that the language
> does not only provide boiler plate []basicType enhanced types,
> but provides streamed version of them,
> that d be much better.
>
> when you do
> [15Million]string.map().filter().count().
>
> with a naive implementation over array of those intents,
> you effectively end up with a copy at each stage,
> which is not cool.
>
> Instead if that d be a stream api,
> that d be almost same call, with small changes to be determined,
> but a much better allocation,
> as each item is processed once by each function, one item at a time,
> you don t need the intermediate (stupid, after all) arrays.
>
> [15Million]string.map().filter().count().
>
> The difference being
> that some func call must become terminal, count() int
> some must probably become contiguous to <something to be decided by the
> user>, filter() stream
>
> can this help to reduce over multiple goroutine?
>
> something like ?
> [15Million]string.chunks(size int, concurrent int).Parrallel(receiver
> []string{}.filter() stream).count().
>
> count is sequential, it receives results from // filters,
> receiver is a worker space (memory+work) aka what a stream ? a []string ?,
>
> so ParrallelChunk is (input stream/[]string) stream/[]string
>
> why not ?
>
> On Tuesday, May 30, 2017 at 4:43:54 PM UTC+2, [email protected] wrote:
>>
>> I m just gonna add more examples as it come,
>>
>> from
>> hasPrefix := func(prefix string) func(string) bool {
>> return func(s string) bool { return strings.HasPrefix(s,
>> prefix) }
>> } // this is not cool....
>>
>> if fnUtils.AllTypes().Filter(hasPrefix("post")).NotEmpty() {
>> ...
>> }
>>
>> to
>> hasPrefix, _ := conv(func(prefix string) func(s string) bool,
>> strings.HasPrefix)
>> // does this make sense given
>> https://golang.org/pkg/strings/#HasPrefix ?
>>
>> if fnUtils.AllTypes().Filter(hasPrefix("post")).NotEmpty() {
>> ...
>> }
>>
>> On Friday, May 26, 2017 at 2:47:45 PM UTC+2, [email protected] wrote:
>>>
>>> oops... mistake in it.
>>>
>>>
>>> printS, err := conv(func(s string, err error), fmt.Println) or panic(err)
>>> _, err := []string{"hello}.Map(strings.
>>> ToUpper).MustEach(printS) or panic(err)
>>>
>>> count, err := conv(func(s string) n int, fmt.Println) or panic(err)
>>> n := []string{"hello}.Map(strings.ToUpper).Sum(count)
>>>
>>> count, err := conv(func(s string) (n int, err error), fmt.Println) or
>>> panic(err)
>>> n, err := []string{"hello}.Map(strings.ToUpper).MustSum(count) or
>>> panic(err)
>>>
>>> more like this, take advantage of return type and names to do more
>>> conversion.
>>>
>>> On Friday, May 26, 2017 at 2:45:33 PM UTC+2, [email protected] wrote:
>>>>
>>>> or this,
>>>>
>>>> printS, err := conv(func(s string, err error), fmt.Println) or
>>>> panic(err)
>>>> _, err := []string{"hello}.Map(strings.ToUpper).MustEach(printS) or
>>>> panic(err)
>>>>
>>>> count, err := conv(func(n int), fmt.Println) or panic(err)
>>>> n := []string{"hello}.Map(strings.ToUpper).Sum(count)
>>>>
>>>> count, err := conv(func(n int, err error), fmt.Println) or panic(err)
>>>> n, err := []string{"hello}.Map(strings.ToUpper).MustSum(count) or
>>>> panic(err)
>>>>
>>>> that'd be great...
>>>>
>>>> On Friday, May 26, 2017 at 2:25:37 PM UTC+2, [email protected] wrote:
>>>>>
>>>>> for the fun,
>>>>>
>>>>> I want to write
>>>>> []string{"hello}.Map(strings.ToUpper).Each(fmt.Println)
>>>>>
>>>>> would not work, func param are incompatible.
>>>>>
>>>>> let s apply static rules to convert it,
>>>>>
>>>>> printS, err := conv(func(s string), fmt.Println) or panic(err)
>>>>> []string{"hello}.Map(strings.ToUpper).Each(printS)
>>>>>
>>>>> Now it s possible.
>>>>>
>>>>> And if one does a fmt.MustPrintln to get ride of the error while still
>>>>> handling it (recoverable)
>>>>> rather than ignore it as of today,
>>>>> you can write that, and handle error via recover,
>>>>> or simply ignore it as in the previous ex.
>>>>>
>>>>> printS, err := conv(func(s string), fmt.MustPrintln) or panic(err)
>>>>>
>>>>> []string{"hello}.Map(strings.ToUpper).Each(printS)
>>>>>
>>>>>
>>>>>
>>>>> On Wednesday, May 24, 2017 at 9:52:27 AM UTC+2, [email protected]
>>>>> wrote:
>>>>>>
>>>>>> see the title, only for what s needed
>>>>>> Slice/Splice/Each/Map/First/Last/Reverse/Sort ect ect not len, for
>>>>>> reason.
>>>>>> so interface system serves the userland by its definition of struct, and
>>>>>> the basic slice type provided by the language is fully operational,
>>>>>> without
>>>>>> breaking, btw. i don t go further in evaluation, i leave that to the
>>>>>> reader, just trying to work decently.
>>>>>>
>>>>>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.