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?
171 Views Asked by dogwood At
2
There are 2 best solutions below
Related Questions in LIST
- Difference between list() and dict() with generators
- python how to write list of lists to file
- SML - Find same elements in a string
- How to divide list item by list item from another list using Python?
- How to get a certain element in a list of lists?
- How to read in numbers from n lines into a Scala list?
- Create a list of sequential monthly dates in PHP given initial date and quantity
- Python elegant way to sort numerically named directories
- sorting all data on multiple pages by clicking on its header
- List item keeps same memory address following sort/copy
- How to convert Hibernate List to String?
- using a for loop to compare lists
- How to keep track of word count in text file
- Running multiprocessing on two different functions in Python 2.7
- How do you fuse string items from two lists into new elements of a new list?
Related Questions in DECLARATION
- Function returning another function
- Is "long long" = "long long int" = "long int long" = "int long long"?
- What is the point of declaring a variable as one class, and allocating memory to it with another class?
- In which part of memory different variables get stored? Who will assign the value to it before starting main?
- What's the benefit for a C source file include its own header file
- Error: Not found: Value S (Scala)
- How to properly declare handlers
- Php Variable declaration error - MySQL
- Where is the AMPathPopUpButton class declared?
- Expected identifier in C
- C++ declaring multiple variables in the same line
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oxm:jaxb2-marshaller'
- C++ constructor bug
- Error w/declaration on else statement (C++)
- Angular: when using ng-include, number variable become NaN
Related Questions in PREDICATE
- Passing a predicate that was passed in as a parameter
- How to use predicates with LINQ to query CRM 2011
- Linq predicate query results is not working for further Linq Join
- Uniqueness and other restrictions for Arbitrary in QuickCheck
- operators in predicate as argument in lambda expression
- Swapping a specific number in list 1 with a specific number in list 2
- how can I make equals predicate returns non case sensitive result in hazelcast values(Predicate arg0) function
- how to pair items from two lists
- Guava multiple interface and generics, got error "The method XXX in the type XXX is not applicable for the arguments"
- predicate to compare Int32
- When does HIVE (not) use WHERE clause on partition as predicate filter
- How to store bool result of a CUDA kernel function
- Check if file exists for content based routing
- Check string for 1 number, 1 letter and be between 5-15 characters in length
- Return value if passes predicate, else default
Related Questions in MERCURY
- How do I compile for debugging in Mercury programming language?
- How to declare a pred for a predicate that imports or outputs lists?
- How continue line of text to next line in Mercury?
- How do I display a list of long integers? (Mercury language)
- Windows mistakes mmc for Microsoft Management Console when it should be Melbourne Mercury Compiler
- Mercury List Unification
- polymorphic instances for typeclasses in Mercury language
- Need to install Mercury compiler
- in windows how to compile and run mercury program
- Are algebraic predicates supported in Mercury?
- How do I specify compile time defines in Mercury?
- What causes type error in argument(s) of functor `field_name/1' in Mercury?
- Convert List to List of Tuples In Mercury
- Mercury installation
- What is a good data type for representing arbitrary binary data?
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)
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?
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