schemedoc / cookbook

New Scheme Cookbook
https://cookbook.scheme.org
29 stars 3 forks source link

new recipes #43

Closed jcubic closed 3 months ago

jcubic commented 2 years ago

Few recipes (some from my implementation as-is and some modified). The best IMHO is sorted? it can be renamed to ordered? using two other recipes.

I think that my take function, which is part of SRFI-1, is better because the list should be the last argument, otherwise you can't curry easily that function. The same argument I've seen in a video some time ago about Lodash (and underscore) JavaScript libraries, that had broken arguments and you could not use curry with them. Because an array was the first argument.

arthurgleckler commented 2 years ago

On Thu, Aug 12, 2021 at 8:56 AM Jakub T. Jankiewicz < @.***> wrote:

Few recipes (some from my implementation as-is and some modified). The best IMHO is sorted? it can be renamed to ordered? using two other recipes.

I think that my take function, which is part of SRFI-1, is better because the list should be last otherwise you can curry easily that function. The same argument I've seen in a video some time ago about Lodash (and underscore) JavaScript libraries, that had broken arguments and you could not use curry with them. Because an array was the first argument.

Consider adding a procedure, say flip, that takes a two-argument procedure and returns a new one with its arguments flipped. Then you can do (flip take) to get the more easily curried version.

jcubic commented 2 years ago

I have in fact implementation of this function in my Scheme, I took those functional programming tools, from RambdaJS library that have very well defined API for function manipulation.

(define (flip fn)
  "(flip fn)

   Higher order function that return new function where first two arguments are swapped.

   Example:

     (define first (curry (flip vector-ref) 0))
     (first #(1 2 3))
     ;; ==> 1"
  (typecheck "flip" fn "function")
  (lambda (a b . rest)
    (apply fn b a rest)))

This is how this function works in Ramda, it swap first two arguments.

lassik commented 2 years ago

SRFI 197: Pipeline Operators solves the problem another way: you type an underscore _ in the place where the argument should be inserted.

lassik commented 2 years ago

The argument order of take is indeed cumbersome. map and for-each are even worse! But defining new standard procedures with the order flipped would probably cause more confusion than it solves, since we would end up with two procedures that do the same job. Using flip or chain in one's own program is a good solution.

jcubic commented 2 years ago

Will change take to be the same as inn SRFI then.

jcubic commented 2 years ago

@lassik I also added another solution for the map recipe since you can understand the problem in two ways.

jcubic commented 2 years ago

Hi, sorry about the late response. I was busy with other things. I've updated the code. in some cases, I used two implementations, added a link to SRFI, or renamed the function.

jcubic commented 3 months ago

I've changed the Map over n consecutive elements recipe to only be called to full length sub lists.

What else needs to be done here?

lassik commented 3 months ago

Sorry, I'm too slow to respond to these updates in a timely manner. Scheme.org should add content faster, and I should not be a gatekeeper that slows it down.

If you don't get a response from anyone within a day, just add what you think is needed. We can always change and revert things later.

We use rsync to upload everything to our Linux server. Let me know if you want an account there.

lassik commented 3 months ago

Now up at https://cookbook.scheme.org/

jcubic commented 3 months ago

Do you manually copy the files? Maybe it's good idea to setup GitHub action that will upload the files to the server after merge.

Let me know if you need help with this. I can setup the workflow, but I need to know how to build the files, and you will need to add SSH key into secrets of the repo, I'm not sure if you can do this on org level. I use scp in one of the project to build website and upload to the server/hosting.

You can see similar workflow here (for my personal blog):

https://github.com/jcubic/jankiewicz/blob/master/.github/workflows/build.yaml

It requires Private SSH key as secret in the repo. But only the person that add the secret can see it, so it's safe for one admin to add the secret and not need to worry that other will see it.

arthurgleckler commented 3 months ago

On Sat, Apr 6, 2024 at 10:05 AM Jakub T. Jankiewicz < @.***> wrote:

Do you manually copy the files? Maybe it's good idea to setup GitHub action that will upload the files to the server after merge.

No, there's a script https://github.com/schemedoc/docs.scheme.org/blob/master/scripts/upload.sh that does it.

Let me know if you need help with this. I can setup the workflow, but I need to know how to build the files, and you will need to add SSH key into secrets of the repo, I'm not sure if you can do this on org level. I use scp in one of the project to build website and upload to the server/hosting.

I'll leave it up to Lassi to decide whether to do this. Our current system doesn't require much work. We just have to keep up with the reviews. I've been trying to keep up, but must have missed some.

Message ID: @.***>

lassik commented 3 months ago

If we can make a Docker container that builds the HTML files (using our Scheme scripts) and uploads them using rsync, that would be ideal IMHO. We can make a dedicated SSH account for CI jobs if it helps.

lassik commented 3 months ago

We just have to keep up with the reviews. I've been trying to keep up, but must have missed some.

It's inevitable. Lisp doesn't attract enough people with the right personality to maintain good websites on a fast schedule.

The GNU sites are the only professional-looking Lisp sites. Even Clojure doesn't have a sleek website though many commercial companies are using it.

Do-ocracy in all the details has to be the main driver of Scheme.org -- once we have written the charter to ensure that the basic structure and technical choices behind the site enjoy wide agreement.

arthurgleckler commented 3 months ago

On Sat, Apr 6, 2024 at 12:30 PM lassik @.***> wrote:

We just have to keep up with the reviews. I've been trying to keep up, but must have missed some.

It's inevitable. Lisp doesn't attract enough people with the right personality to maintain good websites on a fast schedule.

Trying to push Jakub's new entry, I've realized that I haven't been keeping up at all. I was thinking of Schemedoc when I wrote the above. I can't even get the www.sh in the cookbook to run ("cannot import from undefined module: colorize").

Message ID: @.***>

arthurgleckler commented 3 months ago

On Sat, Apr 6, 2024 at 12:36 PM Arthur A. Gleckler @.***> wrote:

Trying to push Jakub's new entry, I've realized that I haven't been keeping up at all. I was thinking of Schemedoc when I wrote the above. I can't even get the www.sh in the cookbook to run ("cannot import from undefined module: colorize").

Okay, it's up. I've updated the comments to explain what to do.

Message ID: @.***>

lassik commented 3 months ago

Sorry, the outdated installation instructions are my fault. Thank you for fixing them.

jcubic commented 3 months ago

I will create an issue for the workflow, so it's easier to find.