{"id":3804,"date":"2024-09-07T18:25:35","date_gmt":"2024-09-07T18:25:35","guid":{"rendered":"https:\/\/workhouse.sweetdishy.com\/?p=3804"},"modified":"2024-09-07T18:25:35","modified_gmt":"2024-09-07T18:25:35","slug":"length-calculation","status":"publish","type":"post","link":"https:\/\/workhouse.sweetdishy.com\/index.php\/2024\/09\/07\/length-calculation\/","title":{"rendered":"Length Calculation"},"content":{"rendered":"\n<p id=\"Arti00011908\">This is used to find the length of list L. We will define one predicate to do this task. Suppose the predicate name is list_length(L,N). This takes L and N as input argument. This will count the elements in a list L and instantiate N to their number. As was the case with our previous relations involving lists, it is useful to consider two cases \u2212<\/p>\n\n\n\n<ul class=\"wp-block-list\" id=\"Arti00011909\">\n<li>If list is empty, then length is 0.<\/li>\n\n\n\n<li>If the list is not empty, then L = [Head|Tail], then its length is 1 + length of Tail.<\/li>\n<\/ul>\n\n\n\n<p id=\"Arti00011912\">To find length of a list in Prolog, add the lines given below in kb5.pl file and then execute as shown in Figure.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/learning.oreilly.com\/api\/v2\/epubs\/urn:orm:book:9789357053778\/files\/images\/img_p579-1.png\" alt=\"images\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/learning.oreilly.com\/api\/v2\/epubs\/urn:orm:book:9789357053778\/files\/images\/img_p579.png\" alt=\"images\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This is used to find the length of list L. We will define one predicate to do this task. Suppose the predicate name is list_length(L,N). This takes L and N as input argument. This will count the elements in a list L and instantiate N to their number. As was the case with our previous [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3341,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[464],"tags":[],"class_list":["post-3804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-language-prolog"],"jetpack_featured_media_url":"https:\/\/workhouse.sweetdishy.com\/wp-content\/uploads\/2024\/08\/programming.png","_links":{"self":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/comments?post=3804"}],"version-history":[{"count":1,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3804\/revisions"}],"predecessor-version":[{"id":3805,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/posts\/3804\/revisions\/3805"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/media\/3341"}],"wp:attachment":[{"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/media?parent=3804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/categories?post=3804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/workhouse.sweetdishy.com\/index.php\/wp-json\/wp\/v2\/tags?post=3804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}