prologiso-prolog

How to find string length using prolog


I have got a method length(list,var) which gives me the length of a list but i want to find the length of a String, anyone with a solution ?


Solution

  • was just playing with it and i gave the predicate as

    ?- length("hello", R).
    R = 5.
    

    surprisingly it worked :)