Back to Blog
Prolog write6/17/2023 ![]() This is also a useful predicate in prolog. ![]() ![]() In this case, we used ‘nl’ predicate to break the line, ‘nl’ is a formatting predicate that tells to prolog to break the line and to go on printing on the next line. If we want six spaces in between the two letters then we can use tab predicate but we have to give arguments to it, which means if we want 6 spaces then pass argument 6 in tab. In this case, we can give space by using tab predicate. ![]() It means that we can put more than one space but we have to tell that to prolog to print it. In this case, we have given 5 spaces between two letters. In this case, we put write(‘ ‘) to print the space between two letters that are m,n, because when we write commands one after the other then it will automatically print one after the other means it will not take space so that we need to tell prolog to print space as ‘write(‘ ‘)’. In this case, we can say that prolog allow to writes two ‘write’ commands one after the other and the output is continuous, which means it will not take space or comma automatically. Let us see how to use two write/1 commands in prolog, o write(m),write(n). This is a case where we can give values to the term, here we given the value to the E and that will also be shown in the output because it contains the variable. Now we will see when it will returns the contains variables, o write(D).Īs above when we call the variable it will return the contains variable with its value prefix with _(underscore). If we want elements to be arranged in a user-friendly format then we can follow the above examples as per the needs. The above query will give output as shown above. The working of built-in predicate write/1 is as following, it taking terms and that will print on the screen with user-friendly notations so that user can understand it.
0 Comments
Read More
Leave a Reply. |