Document lset.
This commit is contained in:
		
							parent
							
								
									d2eed31892
								
							
						
					
					
						commit
						7a260595d2
					
				
					 1 changed files with 81 additions and 0 deletions
				
			
		
							
								
								
									
										81
									
								
								doc/utils.md
									
										
									
									
									
								
							
							
						
						
									
										81
									
								
								doc/utils.md
									
										
									
									
									
								
							|  | @ -68,6 +68,87 @@ predicate. | |||
| 
 | ||||
| ### Set (List) | ||||
| 
 | ||||
|     (import util-set-list) | ||||
| 
 | ||||
| This module implements linear-time set with custom comparator. | ||||
| 
 | ||||
|     (make-lset [comparator]) | ||||
| 
 | ||||
| * ```comparator``` - comparison procedure, defaults to ```equal?``` | ||||
| 
 | ||||
| Creates new lset with given comparator. | ||||
| 
 | ||||
|     (lset-empty? ls) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| 
 | ||||
| Returns ```#t``` if given lset contains no elements. | ||||
| 
 | ||||
|     (lset-member? ls el) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| * ```el``` - element to check | ||||
| 
 | ||||
| Returns ```#t``` if given element ```el``` is contained in the lset | ||||
| ```ls``` using its equality comparator. | ||||
| 
 | ||||
|     (lset-count ls) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| 
 | ||||
| Returns the number of elements in given lset. | ||||
|    | ||||
|     (lset-add ls [el ...]) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| * ```el``` - element(s) to add | ||||
| 
 | ||||
| Adds given element(s) ```el``` to the lset instance ```ls``` returning | ||||
| a new lset instance. | ||||
| 
 | ||||
|     (lset-remove ls el) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| * ```el``` - element to remove | ||||
| 
 | ||||
| If given lset instance ```ls``` contains the element ```el``` | ||||
| provided, it is removed and the new lset is returned. If the element | ||||
| is not contained in ```ls```, it is returned intact. | ||||
| 
 | ||||
|     (list->lset lst [comparator]) | ||||
| 
 | ||||
| * ```lst``` - list to convert | ||||
| * ```comparator``` - equality comparison procedure, defaults to ```equal?``` | ||||
| 
 | ||||
| Returns a new lset with the comparator provided containing all | ||||
| elements in given list. | ||||
| 
 | ||||
|     (lset->list ls) | ||||
| 
 | ||||
| * ```ls``` - lset instance | ||||
| 
 | ||||
| Returns the list of elements in given lset. | ||||
| 
 | ||||
|     (lset-merge ls1 ls2) | ||||
| 
 | ||||
| * ```ls1``` - lset instance | ||||
| * ```ls2``` - lset instance | ||||
| 
 | ||||
| Returns a new lset instance with all elements in both lset instances given. | ||||
| 
 | ||||
|     (lset-intersect ls1 ls2) | ||||
| 
 | ||||
| * ```ls1``` - lset instance | ||||
| * ```ls2``` - lset instance | ||||
| 
 | ||||
| Returns a new lset instance containing elements present both in | ||||
| ```ls1``` and ```ls2```. | ||||
| 
 | ||||
|     (lset-subtract ls1 ls2) | ||||
| 
 | ||||
| Returns a new lset instance from ```ls1``` with all elements in | ||||
| ```ls2``` removed from it. | ||||
| 
 | ||||
| ### String | ||||
| 
 | ||||
|     (import util-string) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue