667 search results for ""
-
Sets
Filtering a Set
The function StringSet.filter of type (string -> bool) -> StringSet.t -> StringSet.t creates a new set by keeping the elements that satisfy a predicate from an existing set.
Data Structures -
Profiling
.data
.long writes a word (4 bytes) to the current segment. .byte writes a single byte. .ascii writes a string of bytes (NOT nul-terminated). .space writes the given number of zero bytes. Normall
Guides -
Maps
Filtering a Map
To filter a map, use the filter function. It takes a predicate to filter entries and a map. It returns a new map containing the entries satisfying the predicate.
Data Structures -
Preprocessors and PPXs
PPXs
PPxs are a different kind of preprocessor—one that does not run on the textual source code, but rather on the parsing result: the Abstract Syntax Tree (AST), which in the OCaml compiler is call
Advanced Topics -
Arrays
Length of an Array
The Array.length function returns the size of an array:
Data Structures -
File Manipulation
Example
<!-- $MDX dir=examples --> We can compile and run this example: <!-- $MDX file=examples/file_manip.ml -->
Tutorials -
Maps
Map a Map
The keys are the same in both maps. For each key, a value in lucky_numbers is converted into a value in lucky_strings using string_of_int . Using StringMap.map , we create a map associatin
Data Structures -
Sets
Conclusion
We gave an overview of OCaml's Set module by creating a StringSet module using the Set.Make functor. Further, we looked at how to create sets based on a custom comparison function. For more in
Data Structures -
Sets
Union of Two Sets
With the function StringSet.union , we can compute the union of two sets.
Data Structures -
Sets
Working With Sets
Let's look at a few functions for working with sets using these two sets.
Data Structures -
Maps
Conclusion
For more information, refer to Map in the Standard Library documentation. This was an overview of OCaml's Map module. Maps are reasonably efficient and can be an alternative to the imperativ
Data Structures -
Maps
Working With Maps
Throughout the rest of this tutorial, we will use the following map:
Data Structures -
Configuring Your Editor
Vim
After installing Merlin above, instructions will be printed on how to link Merlin with your editor. If you do not have them visible, just run this command: For Vim, we won't use the LSP server b
Tooling -
Profiling
.text
Text is the Unix way of saying "program code". The text segment simply means the part of the executable where program code is stored. The .text directive switches the assembler so it starts w
Guides -
Operators
Goals
Using operators as functions and reciprocally, using functions as operators Assign the right associativity and precedence to a custom operator Use and define custom let binders The learning goals o
Advanced Topics -
First-Class Modules
Heterogeneous Collections
Module System -
First-Class Modules
Plugin Registry
Module System