schemedoc / cookbook

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

Amb #40

Closed jcubic closed 2 years ago

jcubic commented 2 years ago

Amb operator using syntax-rules based on Nils M. Holm code #34

jcubic commented 2 years ago

@lassik I was not sure about the name of the files and titles. Maybe you have an idea how to name them.

lassik commented 2 years ago

Thanks for preparing this!

exists? could be called find-stride. It finds a "stride" of adjacent elements satisfying p across many lists. We could think of it as searching for a column across a matrix, but a matrix has the same number of elements in each column, whereas this procedure can handle a different number of elements.

The procedure doesn't always return a boolean (#t/#f), rather it returns the return value of p. Hence find is a more precise name than exists?.

I'd suggest the following renames:

exists? -> find-stride
find-if-element-exists-in-list.md -> find-stride-across-lists.md
# Test whether a given property exists in a sequence of N lists -> Find stride across lists
amb.md -> nondeterminism-using-amb.md
# Nondeterminism using amb
lassik commented 2 years ago

It's been more than a day, so I'll merge this. We can always make new commits if you want to edit things later.

jcubic commented 2 years ago

@lassik thanks for updating the files.