Erlang/OTP Forums

Author Message

<  Erlang  ~  Iterate through a nested list of strings?

dgulino
Posted: Wed Mar 16, 2011 8:15 pm Reply with quote
Joined: 01 Mar 2011 Posts: 5
Probably simple, but how do you iterate through a nested list of strings? (A list of lists of strings (which are lists) ). And I can't flatten the list; I need to act upon the structure of the deep list.

Code:

List = ["States",["Kansas",["Lawrence","Topeka"],"Illinois"]].

hd(List). -> "States"
tl(List). -> [["Kansas",["Lawrence","Topeka"],"Illinois"]]



How do I determine that hd(List) is a terminating case (I want to stop iterating), when "States" is a list also? I can't go by length, or is_list.

Code:

is_list(hd(List)). -> true
length(hd(List)). -> 6
hd(hd(List)). -> 83
tl(hd(List)). -> "tates"

length(tl(List)). -> 1
View user's profile Send private message
dgulino
Posted: Mon Mar 21, 2011 2:40 pm Reply with quote
Joined: 01 Mar 2011 Posts: 5
Evan Miller answered this:

Use erlang:is_integer/1 to test for a string value.
View user's profile Send private message
dongdongwu
Posted: Thu Sep 20, 2012 6:05 am Reply with quote
User Joined: 19 Sep 2012 Posts: 236
His good friend Diane said: "Christian Louboutin Men Shoes was a magician, he make shoes is immediately put his female people with legs and advantage. He understands women wanted to do and can make them into beautiful Cinderella." Madonna often in its concert wearing Christian louboutin high heels , and some famous superstar like Angelina jolie, mariah Carey, beyonce Knowles, the famous Japanese singer YaYouMei Hamasaki helps Christian Louboutin Men Shoes set up its powerful position. The youngest customers will count Tom cruise's daughter sully cruz. Louboutin made for only a pair of handmade Christian Louboutin high heel Shoes! Want to be more fashion? Put on Christian Louboutin Outlet !
Candy colors of the chalaza high-heeled shoes with lolita type allure, set full finely gem blue "neon shoes" is to need to use "sexy" to describe. Each pair are worth careful appreciation of lithe and graceful fairy ludaoli, what kind of most let you move?Christian Louboutin Men Shoes that one brush red is always cannot resist the temptation, Christian Louboutin men outlet continue to use the days of high 8cm above slender heel proclaim the sexy and luxuriant. The bowknot on black pointed high-heeled shoes with sharp rivet concomitant, wild python met enchanting color printing grain, It is that pairs of high-heeled shoes lets Carrie more feminine flavour. Like Christian Louboutin for men her word.
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum