Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
No tip or payment needed for me.  If at some point you desperately want to
toss some money to someone for Clojure, one possibility is to make periodic
small payments to Cognitect Labs, which also gives you access to a tool
called REBL that you may find useful at some point if you continue using
Clojure for development: https://www.patreon.com/cognitect/posts

The syntax #(.contains value %) creates an anonymous function that takes
one argument, and the % represents where the argument is used in the
function body.

If it makes more sense, you can replace it with (fn [x] (.contains value
x)), which will do the same thing.

Yes, every? and some are similar to each other, with every? doing the AND
of all individual function calls on the elements in the sequence, and some
doing the OR, and not only doing the OR, but also returning the value of
the first call that returns a logical true value (anything except nil or
false).

There are Clojurians Slack and ZulipChat chat channels called #beginners
that are also useful for getting started problems.

Andy


On Sat, Jun 22, 2019 at 11:41 AM Thad Guidry  wrote:

> Beautiful Andy!  Can you confirm that last syntax for me?
> I see it as treating the anonymous function of #(.contains value %) as the
> predicate to check on every member of the vector?
> But anonymous function expansion is what throws me off... I need layman's
> terms (grandma speak) to break down the logic there.  Specifically, there
> must be some wiring of the vector members to the % placeholder?
> Ahhh! I guess that what does that actual wiring is the every? function ...
> "for every x in coll"
> So this is just a simple every? invocation I guess.
> And I assume that some would
> be like an or/coalesce, kinda in my usecase ?
> (some #(.contains value %) ["CBS" "Bar" "cat"])
>
> It worked by the way. See screenshot attached.
>
> Still learning a few ropes on Clojure  (and I still can't get the stupid
> nrepl to initialize in my Visual Studio Code with leiningen
>   so
> that doesn't help my learning when I don't have a real dev environment that
> I can learn Clojure against.  Would love someone to help me with that)
>
> Finally, how can I send you a tip or payment for this help?
> Thad
> https://www.linkedin.com/in/thadguidry/
>
>
> On Sat, Jun 22, 2019 at 12:38 PM Andy Fingerhut 
> wrote:
>
>> And, of course you can continue to use .contains:
>>
>> (every? #(.contains value %) ["CBS" "Bar" "cat"])
>>
>>
>>
>> On Sat, Jun 22, 2019 at 10:37 AM Andy Fingerhut 
>> wrote:
>>
>>> I haven't counted characters, but this would certainly become relatively
>>> shorter the more substrings you check for.  It is shown in the context of a
>>> Clojure REPL.  I do not know whether OpenRefine might already do the
>>> require for you, or perhaps even (use 'clojure.string).
>>>
>>> user=> (def value "Bar the cat from CBS")
>>> #'user/value
>>> user=> (require '[clojure.string :as str])
>>> nil
>>> user=> (every? #(str/includes? value %) ["CBS" "Bar" "cat"])
>>> true
>>>
>>> Andy
>>>
>>>
>>> On Sat, Jun 22, 2019 at 10:32 AM Thad Guidry 
>>> wrote:
>>>
 Clojure is supported as an expression language in OpenRefine.  Where
 any cells value in OpenRefine's datagrid is just accessed by the name
 value.
 Here's one of my cells value in OpenRefine...

 "001","878","245","$c","CBS Barmarick Publications,","$c","Emerald"

 and I am trying to see if that cells value contains all of these
 words...

 (and (.contains value "CBS") (.contains value "Bar") (.contains value
 "cat"))

 It works, but I am looking to Clojure experts to find out how to
 shorten this expression?

 -Thad

 --
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/clojure/c37eb1b0-1557-486b-b95a-a5bc53b67b24%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send 

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Thad Guidry
Beautiful Andy!  Can you confirm that last syntax for me?
I see it as treating the anonymous function of #(.contains value %) as the
predicate to check on every member of the vector?
But anonymous function expansion is what throws me off... I need layman's
terms (grandma speak) to break down the logic there.  Specifically, there
must be some wiring of the vector members to the % placeholder?
Ahhh! I guess that what does that actual wiring is the every? function ... "for
every x in coll"
So this is just a simple every? invocation I guess.
And I assume that some would be
like an or/coalesce, kinda in my usecase ?
(some #(.contains value %) ["CBS" "Bar" "cat"])

It worked by the way. See screenshot attached.

Still learning a few ropes on Clojure  (and I still can't get the stupid
nrepl to initialize in my Visual Studio Code with leiningen
  so that
doesn't help my learning when I don't have a real dev environment that I
can learn Clojure against.  Would love someone to help me with that)

Finally, how can I send you a tip or payment for this help?
Thad
https://www.linkedin.com/in/thadguidry/


On Sat, Jun 22, 2019 at 12:38 PM Andy Fingerhut 
wrote:

> And, of course you can continue to use .contains:
>
> (every? #(.contains value %) ["CBS" "Bar" "cat"])
>
>
>
> On Sat, Jun 22, 2019 at 10:37 AM Andy Fingerhut 
> wrote:
>
>> I haven't counted characters, but this would certainly become relatively
>> shorter the more substrings you check for.  It is shown in the context of a
>> Clojure REPL.  I do not know whether OpenRefine might already do the
>> require for you, or perhaps even (use 'clojure.string).
>>
>> user=> (def value "Bar the cat from CBS")
>> #'user/value
>> user=> (require '[clojure.string :as str])
>> nil
>> user=> (every? #(str/includes? value %) ["CBS" "Bar" "cat"])
>> true
>>
>> Andy
>>
>>
>> On Sat, Jun 22, 2019 at 10:32 AM Thad Guidry 
>> wrote:
>>
>>> Clojure is supported as an expression language in OpenRefine.  Where any
>>> cells value in OpenRefine's datagrid is just accessed by the name value.
>>> Here's one of my cells value in OpenRefine...
>>>
>>> "001","878","245","$c","CBS Barmarick Publications,","$c","Emerald"
>>>
>>> and I am trying to see if that cells value contains all of these words...
>>>
>>> (and (.contains value "CBS") (.contains value "Bar") (.contains value
>>> "cat"))
>>>
>>> It works, but I am looking to Clojure experts to find out how to
>>> shorten this expression?
>>>
>>> -Thad
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/clojure/c37eb1b0-1557-486b-b95a-a5bc53b67b24%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/CAKvLtDZxWM49qu-CCt-Lzn%3DCiQq%3DQy9MeY0kWV0tP4eHJknVbA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more 

Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
And, of course you can continue to use .contains:

(every? #(.contains value %) ["CBS" "Bar" "cat"])



On Sat, Jun 22, 2019 at 10:37 AM Andy Fingerhut 
wrote:

> I haven't counted characters, but this would certainly become relatively
> shorter the more substrings you check for.  It is shown in the context of a
> Clojure REPL.  I do not know whether OpenRefine might already do the
> require for you, or perhaps even (use 'clojure.string).
>
> user=> (def value "Bar the cat from CBS")
> #'user/value
> user=> (require '[clojure.string :as str])
> nil
> user=> (every? #(str/includes? value %) ["CBS" "Bar" "cat"])
> true
>
> Andy
>
>
> On Sat, Jun 22, 2019 at 10:32 AM Thad Guidry  wrote:
>
>> Clojure is supported as an expression language in OpenRefine.  Where any
>> cells value in OpenRefine's datagrid is just accessed by the name value.
>> Here's one of my cells value in OpenRefine...
>>
>> "001","878","245","$c","CBS Barmarick Publications,","$c","Emerald"
>>
>> and I am trying to see if that cells value contains all of these words...
>>
>> (and (.contains value "CBS") (.contains value "Bar") (.contains value
>> "cat"))
>>
>> It works, but I am looking to Clojure experts to find out how to shorten
>> this expression?
>>
>> -Thad
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/clojure/c37eb1b0-1557-486b-b95a-a5bc53b67b24%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAKvLtDZxWM49qu-CCt-Lzn%3DCiQq%3DQy9MeY0kWV0tP4eHJknVbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Shorter form to check if some words are contained in a sentence?

2019-06-22 Thread Andy Fingerhut
I haven't counted characters, but this would certainly become relatively
shorter the more substrings you check for.  It is shown in the context of a
Clojure REPL.  I do not know whether OpenRefine might already do the
require for you, or perhaps even (use 'clojure.string).

user=> (def value "Bar the cat from CBS")
#'user/value
user=> (require '[clojure.string :as str])
nil
user=> (every? #(str/includes? value %) ["CBS" "Bar" "cat"])
true

Andy


On Sat, Jun 22, 2019 at 10:32 AM Thad Guidry  wrote:

> Clojure is supported as an expression language in OpenRefine.  Where any
> cells value in OpenRefine's datagrid is just accessed by the name value.
> Here's one of my cells value in OpenRefine...
>
> "001","878","245","$c","CBS Barmarick Publications,","$c","Emerald"
>
> and I am trying to see if that cells value contains all of these words...
>
> (and (.contains value "CBS") (.contains value "Bar") (.contains value
> "cat"))
>
> It works, but I am looking to Clojure experts to find out how to shorten
> this expression?
>
> -Thad
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/clojure/c37eb1b0-1557-486b-b95a-a5bc53b67b24%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/CAKvLtDa49XSNFjsA53ou7hcMmMnLeyKe94p_fHR%2BdbGxVA6kzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.