Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #60020 > unrolled thread
| Started by | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| First post | 2017-05-29 17:33 +0000 |
| Last post | 2017-05-30 01:01 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.forth
Rosetta: Split a character string based on change of character "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-29 17:33 +0000
Re: Rosetta: Split a character string based on change of character "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-29 22:40 +0000
Re: Rosetta: Split a character string based on change of character "Robert L." <No_spamming@noWhere_7073.org> - 2017-05-30 07:26 +0000
Re: Rosetta: Split a character string based on change of character Julian Fondren <julian.fondren@gmail.com> - 2017-05-30 01:01 -0700
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2017-05-29 17:33 +0000 |
| Subject | Rosetta: Split a character string based on change of character |
| Message-ID | <oghm17$12gq$1@gioia.aioe.org> |
> Split a (character) string into comma (plus a blank) delimited
> strings based on a change of character (left to right).
> For instance, the string:
>
> gHHH5YY++///\
>
> should be split and show:
>
> g, HHH, 5, YY, ++, ///, \
puts "gHHH5YY++///\\".chars.slice_when{|a,b| a != b}.map(&:join).
join ", "
===>
g, HHH, 5, YY, ++, ///, \
In Forth?
--
Much of what I'll be talking about today is taken from that excellent essay,
which includes incontrovertible mathematical and statistical proof that violent
crime bears a close, nearly direct, relationship to the presence of Blacks and
Mestizos in our midst.
nationalvanguard.org/2014/02/american-dissident-voices-america-race-and-violent-crime/
[toc] | [next] | [standalone]
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2017-05-29 22:40 +0000 |
| Message-ID | <ogi80p$15p$1@gioia.aioe.org> |
| In reply to | #60020 |
On 5/29/2017, Robert L. wrote:
> > Split a (character) string into comma (plus a blank) delimited
> > strings based on a change of character (left to right).
>
> > For instance, the string:
> >
> > gHHH5YY++///\
> >
> > should be split and show:
> >
> > g, HHH, 5, YY, ++, ///, \
>
> puts "gHHH5YY++///\\".chars.slice_when{|a,b| a != b}.map(&:join).
> join ", "
>
> ===>
> g, HHH, 5, YY, ++, ///, \
>
>
> In Forth?
(string-join
(let go ((s "gHHH5YY++///\\"))
(if (string=? "" s)
'()
(let ((m (rxmatch #/^(.)\1*/ s)))
(cons (rxmatch-substring m)
(go (rxmatch-after m))))))
", ")
===>
"g, HHH, 5, YY, ++, ///, \\"
--
In Denmark, a teenage girl was attacked by a Muslim immigrant.... She fought
back, and used a can of pepper spray ... against him.... In the aftermath she
was told that she faced prosecution, as pepper spray is illegal in Denmark.
www.europeancivilwar.com/anarcho-tyranny-and-the-logistical-class
[toc] | [prev] | [next] | [standalone]
| From | "Robert L." <No_spamming@noWhere_7073.org> |
|---|---|
| Date | 2017-05-30 07:26 +0000 |
| Message-ID | <ogj6rk$1798$1@gioia.aioe.org> |
| In reply to | #60032 |
On 5/29/2017, Robert L. wrote:
> On 5/29/2017, Robert L. wrote:
>
> > > Split a (character) string into comma (plus a blank) delimited
> > > strings based on a change of character (left to right).
> >
> > > For instance, the string:
> > >
> > > gHHH5YY++///\
> > >
> > > should be split and show:
> > >
> > > g, HHH, 5, YY, ++, ///, \
> >
> > puts "gHHH5YY++///\\".chars.slice_when{|a,b| a != b}.map(&:join).
> > join ", "
> >
> > ===>
> > g, HHH, 5, YY, ++, ///, \
> >
> >
> > In Forth?
>
> (string-join
> (let go ((s "gHHH5YY++///\\"))
> (if (string=? "" s)
> '()
> (let ((m (rxmatch #/^(.)\1*/ s)))
> (cons (rxmatch-substring m)
> (go (rxmatch-after m))))))
> ", ")
>
> ===>
> "g, HHH, 5, YY, ++, ///, \\"
OCaml:
#load "str.cma";;
let rec loop = function
"" -> []
| s ->
(ignore (Str.string_match (Str.regexp "\\(.\\)\\1*") s 0) ;
let t = (Str.matched_string s) in
t :: (loop (Str.string_after s (Str.match_end()))))
in print_endline (String.concat ", " (loop "gHHH5YY++///\\")) ;;
===>
g, HHH, 5, YY, ++, ///, \
--
Latinos beat, threaten to rape and kill white schoolgirl after finding out she
opposes illegal immigration. -- violenceagainstwhites.wordpress.com/2013/04/29/
[toc] | [prev] | [next] | [standalone]
| From | Julian Fondren <julian.fondren@gmail.com> |
|---|---|
| Date | 2017-05-30 01:01 -0700 |
| Message-ID | <762e90db-3d40-4840-a6eb-10ccc0fcd70f@googlegroups.com> |
| In reply to | #60046 |
On Tuesday, May 30, 2017 at 2:26:48 AM UTC-5, Robert L. wrote:
> On 5/29/2017, Robert L. wrote:
>
> > On 5/29/2017, Robert L. wrote:
> >
> > > > Split a (character) string into comma (plus a blank) delimited
> > > > strings based on a change of character (left to right).
> > >
alright already.
: onchange ( c-addr u xt xt -- ) {: same-xt new-xt | last :} \ u!=0
bounds dup c@ to last do
i c@ dup last = if same-xt else dup to last new-xt then execute
loop ;
: nonsense ( c-addr u -- ) \ u!=0
['] emit [: ." , " emit ;] onchange ;
As used:
s" hello" nonsense h, e, ll, o ok
s" gHHH5YY++///\" nonsense g, HHH, 5, YY, ++, ///, \ ok
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.forth
csiph-web