tiflolinux.org - GNU Social
  • Login

Bienvenido

  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

Conversation

Notices

  1. spectrumgomas@functional.cafe's status on Thursday, 17-Jun-2021 21:27:40 CEST spectrumgomas spectrumgomas

    I have a problem with Mark Mahoney "An Animated Introduction to Clojure" Chapter 3 Interest in an account, but in GNU #guile. What should I write here? https://pastebin.com/W40WLtxa

    In conversation Thursday, 17-Jun-2021 21:27:40 CEST from functional.cafe permalink

    Attachments

    1. interest in an account - Pastebin.com
      Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
    • Abbie Normal (abbienormal@social.device5.co.uk)'s status on Thursday, 17-Jun-2021 22:00:56 CEST Abbie Normal Abbie Normal
      in reply to

      @spectrumgomas

      I see in the clojure version they use a for cycle

      That's strange

      What does the clojure procedure return ?

      A list ? Or maybe a number ?

      Or anything else ?

      If, as I think, you want a list, you could write it like this:

      (map (lambda (interest-function) (interest-function principal year-number)) interest-functions)

      In conversation Thursday, 17-Jun-2021 22:00:56 CEST permalink
    • spectrumgomas@functional.cafe's status on Thursday, 17-Jun-2021 22:00:56 CEST spectrumgomas spectrumgomas
      in reply to
      • Abbie Normal

      @AbbieNormal (interest-functions (map value-after-years-generator rates)) creates a list of partial functions in interest-functions. Now I want apply all these functions and create a list with the results.

      In conversation Thursday, 17-Jun-2021 22:00:56 CEST permalink
    • Abbie Normal (abbienormal@social.device5.co.uk)'s status on Thursday, 17-Jun-2021 22:21:19 CEST Abbie Normal Abbie Normal
      in reply to

      @spectrumgomas

      doesn't this work ?

      (map (lambda (interest-function) (interest-function principal year-number)) interest-functions)

      In conversation Thursday, 17-Jun-2021 22:21:19 CEST permalink
    • spectrumgomas@functional.cafe's status on Thursday, 17-Jun-2021 22:21:19 CEST spectrumgomas spectrumgomas
      in reply to
      • Abbie Normal

      @AbbieNormal I don't think so. interest-functions isn't the list of arguments. It's a list of partial functions.

      In conversation Thursday, 17-Jun-2021 22:21:19 CEST permalink
      Ekaitz Zárraga 👹 repeated this.
    • spectrumgomas@functional.cafe's status on Thursday, 17-Jun-2021 22:47:26 CEST spectrumgomas spectrumgomas
      in reply to
      • Abbie Normal

      @AbbieNormal Ah, I've never seen map over a list of functions before. Then that's probably the solution. Thanks!

      In conversation Thursday, 17-Jun-2021 22:47:26 CEST permalink
    • Abbie Normal (abbienormal@social.device5.co.uk)'s status on Thursday, 17-Jun-2021 22:47:27 CEST Abbie Normal Abbie Normal
      in reply to

      @spectrumgomas

      I know and I apply them, in that code 🙂

      In conversation Thursday, 17-Jun-2021 22:47:27 CEST permalink
      spectrumgomas and Ekaitz Zárraga 👹 repeated this.
    • Abbie Normal (abbienormal@social.device5.co.uk)'s status on Thursday, 17-Jun-2021 22:47:27 CEST Abbie Normal Abbie Normal
      in reply to

      @spectrumgomas

      you can map over a list of functions

      map applies that "lambda" on every function in interest-functions

      and the lambda calls every one of those partial functions with "principal" and "year-number"

      In conversation Thursday, 17-Jun-2021 22:47:27 CEST permalink

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

tiflolinux.org - GNU Social is a social network, courtesy of tiflolinux.org. It runs on GNU social, version 2.0.1-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All tiflolinux.org - GNU Social content and data are available under the Creative Commons Attribution 3.0 license.