[REBOL] Re: Understanding Data Types
From: gjones05:mail:orion at: 7-Jun-2001 17:53
From: "Gary Learned"
> I am a newbie to REBOL and trying to get a grip on it's data typing. My
> question concerns the following scenario:
>
> If I read a directory:
>
> foo: read %.
>
> how can I execute a find against the block? If I try:
>
> find foo "a.txt"
>
> I get a null response, as I do with most other variations. I know that each
> entry in foo is considered a file type, and I am assuming that is why my
> find doesn't work, but what do I need to do to make it work?
Hi, Ed,
You are almost there. You are correct about the entries in foo. What is not
correct is the value you were using to search. "a.txt" is a string. You need a
file type also here.
find foo %a.txt
should do the trick (assuming a.txt is in the directory! ;-). Next thing you
may be surprised about is that find returns the series at the point of the
match. So you may still get a series. To only get the single value, use
'first.
find [1 2 3 4 5] 3 ;returns== [3 4 5]
first find [1 2 3 4 5] 3 ;returns ==3
a: first find [1 2 3 4 5] 3 ;returns ==3 and a now refers to the value.
Hope this helps. REBOL is a great language. Ask all the questions that you
want.
--Scott Jones