What do you want to contribute?

Geoff Canyon gcanyon at gmail.com
Mon Feb 18 20:46:13 EST 2013


yeah, I wasn't happy with that syntax as I was typing it. Part of the
beauty of being able to create/share syntax is that others can improve on
what you come up with, and only the good syntax survives into general
usage. Maybe this would be better:

   put file filePath with all non-alphabetic characters replaced with space
into fileString
   for each unique word w in fileString
      put w,the count of w & cr after countList
   end for
   put the first 10 lines of countList sorted numeric descending by item 2

or maybe this:

   put file filePath with all non-alphabetic characters replaced with space
into fileString
   put ((each unique word w),(the count of w)&cr) in fileString into
countList
   put the first 10 lines of countList sorted numeric descending by item 2

or heck, maybe this -- I rather like the use of "individual" to represent
the non-alphabetic replacement in the earlier examples:

   put the 10 commonest individual words in file filepath along with comma
& the count of each & cr

but again, only actual experimentation with real developers will determine
what makes intuitive sense and what is just useless too-specific jargon.


On Mon, Feb 18, 2013 at 3:20 PM, Monte Goulding <monte at sweattechnologies.com
> wrote:

> Hmm... I think your code using current syntax is actually clearer than the
> proposed syntax. I definitely don't like adding meaningful comma given the
> confusion with items... You could replace that with a semi-colon or new
> line though.
>
> --
> M E R Goulding
> Software development services
>
> mergExt - There's an external for that!
>
> On 18/02/2013, at 5:13 PM, Geoff Canyon <gcanyon at gmail.com> wrote:
>
> > Here's an interesting real(ish) world example:
> > http://www.leancrew.com/all-this/2011/12/more-shell-less-egg/
> >
> > The goal is to find the ten most common words in a text file.
> >
> > Donald Knuth wrote something in literate code form, in Pascal. The result
> > was ten pages of code. In the article, Doug McIlroy wrote it in shell
> > script as:
> >
> > 1  tr -cs A-Za-z '\n' |2  tr A-Z a-z |3  sort |4  uniq -c |5  sort -rn
> > |6  sed ${1}q
> >
> > and called out Knuth on his supposedly more clear, ten-page solution.
> >
> > It turns out six lines of transcript accomplishes the same thing:
> >
> >   repeat for each word w in replacetext(url ("file:" &
> > filePath),"(?i)[^a-z]"," ")
> >      add 1 to c[w]
> >   end repeat
> >   combine c using cr and comma
> >   sort lines of c descending numeric by item 2 of each
> >   put line 1 to 10 of c
> >
> > If anyone can do it more elegantly, I'm curious to know how. But in a
> > language where we can write our own syntax, this seems likely to be
> > possible:
> >
> > put file filePath with all non-alphabetic characters replaced with space
> > into fileString
> > for each unique word w in fileString, put w,the count of w & cr after
> > countList
> > put the first 10 lines of countList sorted numeric descending by item 2
> >
> > Maybe that's not clearer, but it should be possible.
> >
> >
> > On Thu, Feb 14, 2013 at 4:14 PM, Geoff Canyon <gcanyon at gmail.com> wrote:
> >
> >>
> >> On Thu, Feb 14, 2013 at 2:08 PM, Monte Goulding <
> >> monte at sweattechnologies.com> wrote:
> >>
> >>> In my example I used "each line OF x" rather than "each line IN x". I
> >>> often get caught on repeat for each line X IN y when I write OF. Could
> I
> >>> add OF to the repeat syntax so it didn't matter? It seems natural to me
> >>> either way. If not then perhaps our syntax should be:
> >>>
> >>> trim each line in X
> >>
> >>
> >> The impression I got was that the new language ability would make it
> >> fairly simple (or at least possible) to allow for either of or in. I'm
> >> right there with you -- I don't actually code that often anymore, but
> >> nearly every time I do, I mix up of and in. In my perfect world the
> >> prepositions would be interchangeable and likely not significant, so of,
> >> in, through, across, within, and maybe others.
> >>
> >> gc
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list