Skip to content

Commit

Permalink
Modified documents
Browse files Browse the repository at this point in the history
  • Loading branch information
sasagawa888 committed May 22, 2021
1 parent 332a894 commit a48790f
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 4 deletions.
24 changes: 22 additions & 2 deletions documents/COMBINATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,28 @@ Thanks to Mr. Hiroi.
```

# Specification

See the following test cases:
- selects xs => list
Select element, store selected element in CAR, store remaining elements in CDR, store it in list and return
- permutation fn n xs => nil
Generate a permutation that selects n elements from the list xs
- permutations n xs => list
Generate a permutation that selects n elements from the list xs
- permutation-with-repetition fn n xs => nil
Generate a permutations with n elements from the list xs
- permutations-with-repetition n xs => list
Generate a permutations with n elements from the list xs
- combination-number n r
Find the number of combinations nCr
- combination fn n xs => nil
Generate a combination that selects n elements from the list xs
- combinations n xs => list
Generate a combination that selects n elements from the list xs
- combination-with-repetition fn n xs => nil
Generate duplicate combinations that select n elements from the list xs
- combinations-with-repetition n xs => list
Generate duplicate combinations that select n elements from the list xs

# Test cases

```lisp
(test (selects '(1 2 3)) ((1 2 3) (2 1 3) (3 1 2)))
Expand Down
80 changes: 79 additions & 1 deletion documents/LIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,86 @@ Thanks to Mr. Hiroi.
```

# Specification
- cxxr, cxxxr, cxxxxr
combination of car and cdr
- first, second, ..., tenth
Find the elements of the list
- last-pair xs
Find the last cell of list xs
- last xs
Find the last element of list xs
- take xs n
Extract n elements from the beginning of list xs
- drop xs n
Remove n elements from the beginning of list xs
- revappend xs ys
Invert list xs and concatenate with ys
- copy-list xs
Copy the top level of the list xs
- copy-tree tree
Copy the entire list tree
- copy-alist alist
Copy the associative list alist
Only the top level and the cell containing the key and value are copied
- subst new old tree
Equal to old (eql) Replace elements in list tree with new
- subst-if new pred tree
Replace the element for which the predicate pred returns true with new
- subst-if-not new pred tree
Replace elements where the predicate pred returns false with new
- iota n m
Generate a sequence (list) of integers from n to m
- tabulate f n m
Stores and returns the values of f (n), ..., f (m) in a list
- unfold p f g seed
Unraveling (reverse convolution)
Stores the value of f (seed) in a list and returns it. The next term is generated by g (seed). When p (seed) is true, the list generation ends.
- fold-left f a xs1 [xs2 ...]
Fold from the top of the list
Cumulative value is passed as the first argument of the function f, and the elements of the list are passed after that.
- fold-right f a xs1 [xs2 ...]
Convolution from the end of the list
Cumulative value is passed as the first argument of the function f, and the elements of the list are passed after that.
- for-each f xs1 [xs2 ...]
Apply the function f to the elements of the list
- partition pred xs
Divide the list xs into two by the truth of the predicate pred
- any pred xs1 [xs2 ...]
Apply the predicate pred to the elements of the list and return T if any element returns true.
- all pred xs1 [xs2 ...]
Apply the predicate pred to the elements of the list and return NIL if any element returns false.
- member-if pred xs
Find the first element for which the predicate pred is true
- member-if-not pred xs
Find the first element where the predicate pred is false
- remove-duplicates xs
Remove duplicate elements (use eql for equality determination)
- union xs ys ys
Find the union
- intersection xs ys
Find the intersection
- difference xs ys
Find the difference set
- subsetp xs ys
Returns true if xs is a subset of ys
- acons k v alist
Add key k and value v to the associative list alist
- pairlis ks vs alist
Add key (element of list ks) and value (element of list vs) to alist
- assoc-if pred alist
Find the first key for which the predicate pred returns true
- assoc-if pred alist
Find the first key for which the predicate pred returns false
- rassoc value alist
Equal to value (eql) Find the first value
- rassoc-if pred alist
Find the first value for which the predicate pred returns true
- rassoc-if pred alist
Find the first value for which the predicate pred returns false


See the following test cases:

# Test cases

```lisp
(test (caar '((a b) (c d) (e f))) A)
Expand Down
16 changes: 15 additions & 1 deletion documents/SEQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ Thanks to Mr. Hiroi.
```

# Specification
- list-> vector xs
Convert list xs to vector
- list-> string xs
Convert list xs to a string (list elements must be characters)
- vector-> list xs
Convert vector xs to string
- vector-> string xs
Convert vector xs to a string (vector elements must be characters)
- string-> list xs
Convert a string to a list
- string-> vector xs
Convert a string to a list


# Test cases

See the following test cases:

```lisp
(test (remove 'a '(a b a b c a b c d)) (B B C B C D))
Expand Down

0 comments on commit a48790f

Please sign in to comment.