Looking for help declaring a pred for a predicate that imports or outputs lists. I tried :- pred name(list::in, integer::out) is multi. and compiler error message says that list/0 isn't recognized. Checked library module list and see that I should write something like ...(list(T)::in . . . ), but didn't fully understand what to do.
How to declare a pred for a predicate that imports or outputs lists?
105 views Asked by dogwood At
2
There are 2 answers
Related Questions in LIST
- Force sublime text to use PATH from the shell value
- Sublimetext 3 & AngularJS - Syntax highlighting (HTML)
- Longjohn build fail Titanium
- Open current file in IntelliJ wih Sublime
- Shortcut key to show unsaved changes in Sublime Text 3
- How should I create a build system that can take STDIN in Sublime Text 3 under OSX?
- sublime text next_result open blank file
- Sublime Text line wrap and commit messages
- Sublime Text won't output Java println statements in main method
- Sublime Text: set language for each file
Related Questions in DECLARATION
- Force sublime text to use PATH from the shell value
- Sublimetext 3 & AngularJS - Syntax highlighting (HTML)
- Longjohn build fail Titanium
- Open current file in IntelliJ wih Sublime
- Shortcut key to show unsaved changes in Sublime Text 3
- How should I create a build system that can take STDIN in Sublime Text 3 under OSX?
- sublime text next_result open blank file
- Sublime Text line wrap and commit messages
- Sublime Text won't output Java println statements in main method
- Sublime Text: set language for each file
Related Questions in PREDICATE
- Force sublime text to use PATH from the shell value
- Sublimetext 3 & AngularJS - Syntax highlighting (HTML)
- Longjohn build fail Titanium
- Open current file in IntelliJ wih Sublime
- Shortcut key to show unsaved changes in Sublime Text 3
- How should I create a build system that can take STDIN in Sublime Text 3 under OSX?
- sublime text next_result open blank file
- Sublime Text line wrap and commit messages
- Sublime Text won't output Java println statements in main method
- Sublime Text: set language for each file
Related Questions in MERCURY
- Force sublime text to use PATH from the shell value
- Sublimetext 3 & AngularJS - Syntax highlighting (HTML)
- Longjohn build fail Titanium
- Open current file in IntelliJ wih Sublime
- Shortcut key to show unsaved changes in Sublime Text 3
- How should I create a build system that can take STDIN in Sublime Text 3 under OSX?
- sublime text next_result open blank file
- Sublime Text line wrap and commit messages
- Sublime Text won't output Java println statements in main method
- Sublime Text: set language for each file
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
List is a parametric type, parametric types take one or more parameters. In the case of list the parameter says what this is a list of. You may have a list of numbers, a list of strings, a list of pumpkins or a list of lists of numbers (any valid type). So, if I create a function such as:
This function takes a list of ints and returns an int (the maximum number found in the list).
So, what's with list(T)? A token beginning with a capital letter is a variable, even in types, It can stand for any other type (usually). So "list(T)" means a list of anything, such as a list of numbers or strings. The next predicate is polymorphic, it works for different types depending on the actual values of it's type variable.
A list of anything can be passed as the first item in the list will be returned, if there is one. If this is used with a list of strings "list(string)" then T will be substituted (during compilation) with "string".
The reference for this part of Mercury's type system is here. http://www.mercurylang.org/information/doc-release/mercury_ref/Discriminated-unions.html#Discriminated-unions