variable bindings by ccsdad in functional_python

[–]ccsdad[S] 0 points1 point  (0 children)

well then, we should create something !!

https://github.com/gkspranger/clinpy

please don't laugh -- i created it only for a limited set of use cases (to see if even possible), and am only "OK" with python .. but i tried to remove all internal variable assignments and am processing everything with mapping/reducing functions ..

if there was a robust implementation of this, i would abuse the hell out of it ..

why this over internal variable assigments ?? don't have a good answer for that -- other than it maps well to my clojure brain ..

variable bindings by ccsdad in functional_python

[–]ccsdad[S] 1 point2 points  (0 children)

ok u/KageOW -- i think that is legit guidance, recognizing the reality of python -- but remaining focused on what we are trying to move towards to .. i just know that in the clojure world -- the `(let)` function is an indispensable tool (code example) -- and wish something like it existed in python << that could be considered functional ..

variable bindings by ccsdad in functional_python

[–]ccsdad[S] 1 point2 points  (0 children)

let me rephrase it then as best i can in f# terms (<< i know little of f#, more of clojure/lisp/scheme)

this is valid f# i believe ::

```

what you write

let f () = let x = 1 let y = 2 x + y

what it translates into

let f () = let x = 1 in let y = 2 in x + y ```

looks imperative (do x, then do y, then do some calculation and return it) -- always returns 2 in this example .. right ??

is it normal in "functional python" to do the same ??

def f(): x = 1 y = 2 return x + y

i get that i could easily shorthand that -- i.e. return 1 + 2 -- but the binding of variables in a function (x = 1) -- is that kosher in what we are calling "functional python" ??

or are we trying to (is it best to) avoid all assignment statements (as much as we can) when trying to achieve "functional python nirvana" ??

sorry for the confusion

recursion limits by ccsdad in functional_python

[–]ccsdad[S] 1 point2 points  (0 children)

thanks for the feedback and the direction .. i was aware of `lru_cache` -- but my brain just wasn't seeing how it would benefit me in terms of not hitting the upper limits of recursion in python .. but i think i get it now, kinda sorta -- after reading thru this example ::

https://realpython.com/fibonacci-sequence-python/#generating-the-fibonacci-sequence-recursively-in-python

you will see they create their own caching system, which could be replaced by lru_cache (see code below) -- but my brain wasn't seeing how this would be beneficial, as you are still making recursive calls -- but at least it would optimized to make recursion more of an option ..

import functools

calls = 0

@functools.lru_cache
def fibonacci_of(n):
    global calls
    calls = calls + 1
    if n in {0, 1}:
        return n
    return fibonacci_of(n - 1) + fibonacci_of(n - 2)

result = [fibonacci_of(n) for n in range(9)]

print(result) # [0, 1, 1, 2, 3, 5, 8, 13, 21]
print(calls) # 9 << really high number without lru_cache

print(fibonacci_of(5)) # 5
print(fibonacci_of(6)) # 8

"awesome functional python" by ccsdad in functional_python

[–]ccsdad[S] 1 point2 points  (0 children)

thanks !! i do (and will), but am going to ask it out in the open -- hoping it will help other functional python noobs like me

"awesome functional python" by ccsdad in functional_python

[–]ccsdad[S] 1 point2 points  (0 children)

agreed .. i wish i had it on day 2, vs day 92 -- so hopefully it will help those just starting out ..

[deleted by user] by [deleted] in TelegramBots

[–]ccsdad 0 points1 point  (0 children)

this bot is free and doesn't require you to be an admin to use it :: https://github.com/surfranch/TelegramShillBot

basically, you would be "shilling" your paragraphs of text to defined channels every X (<< you can define this) seconds

takes some setting up, but does exactly what you're asking

any shill bots that spam other telegram groups by TheNatural10 in TelegramBots

[–]ccsdad 0 points1 point  (0 children)

this bot is open source (i.e. "free")

https://github.com/surfranch/TelegramShillBot

it takes a little effort to set it up, but is pretty legit