From: Vladislav Malyshkin <mal@gromco.com>
To: Peter Samuelson <peter@cadcamlab.org>, linux-kernel@vger.kernel.org
Subject: Re: test10-pre7
Date: Fri, 03 Nov 2000 11:26:06 -0500 [thread overview]
Message-ID: <3A02E71E.745138F4@gromco.com> (raw)
In-Reply-To: <39FEF039.69FAFDB2@gromco.com> <14846.63285.212616.574188@wire.cadcamlab.org> <39FF0A71.FE05FAEB@gromco.com> <14847.51541.625121.78324@wire.cadcamlab.org>
Hi, Peter
> [Vladislav Malyshkin <mal@gromco.com>]
> > Also, the function remove_duplicates can be written using make rules
> > and functions. Using functions "foreach" "if" from make and
> > comparison you can easily build a function remove_duplicates in make,
> > no shell involved.
>
> Could you please write me this function? I am curious to see how you
> do it.
>
> I am also a bit skeptical. About 3 months ago, I thought it would be
> possible to do this, so I spent a few hours fiddling around and reading
> documentation. I failed; nothing I tried worked.
>
> > so instead of $(sort) your will have $(remove_duplicates) written
> > entirely in make.
>
> That would make me happy.
Absense of recursive macros in make makes the problem not that clear.
An alternative may be if to put \n into variable value,
so the make commands will be automatically generated
---- like this
remove_duplicates = $(2) := ; $(foreach tmpvar1,$(1),$(2) += $$(if
$$(findstring $(tmpvar1),$$($(2))),,$(tmpvar1)); )
$(call remove_duplicates, x y a a c c a b c,ABCD)
--- in this example the variable ABCD is set to the string without
duplicates
but make seems does not allow \n as a value and does not understand
several assignments in one line, so
A = B ; C = D
does not work as expected.
So the best what we can get without using shell is below (the code and
usage example)
The function $(call remove_duplicates,string with duplicates)
removes the duplicates from the string.
# joins four strings
join4 = $(join $(join $(1),$(2)),$(join $(3),$(4)))
# generates indexes
numbers = $(foreach x4,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x3,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x2,0 1 2 3 4 5 6 7 8 9,\
$(strip $(foreach x1,0 1 2 3 4 5 6 7 8 9,\
$(strip $(if $(findstring $(call join4,$(x4),$(x3),$(x2),$(x1)),0000),,\
$(if $(word $(call join4,$(x4),$(x3),$(x2),$(x1)),$(1)),\
$(call join4,$(x4),$(x3),$(x2),$(x1)))))))))))))
# generates indexes
numbers1 = $(wordlist 1,$(words $(wordlist 2,$(words $(1)),$(1))),\
$(call numbers,$(1)))
# Remove duplicates from a line of up to 10000 words
remove_duplicates = $(strip $(firstword $(1)) \
$(foreach tmpvar,$(call numbers1,$(1)),\
$(if $(findstring \
$(word $(tmpvar),$(wordlist 2,$(words $(1)),$(1))),\
$(wordlist 1,$(tmpvar),$(1))),,\
$(word $(tmpvar),$(wordlist 2,$(words $(1)),$(1))))))
f := x x y a b c d x e y jj jj j2 j2 j2 j7
all:
echo '$(call remove_duplicates,$(f))'
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-03 16:31 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-10-31 16:15 test10-pre7 Vladislav Malyshkin
2000-10-31 16:45 ` test10-pre7 Peter Samuelson
2000-10-31 18:07 ` test10-pre7 Vladislav Malyshkin
2000-10-31 18:38 ` test10-pre7 Linus Torvalds
2000-10-31 19:16 ` test10-pre7 H. Peter Anvin
2000-11-01 3:15 ` test10-pre7 Peter Samuelson
2000-11-01 6:11 ` test10-pre7 H. Peter Anvin
2000-11-01 6:19 ` Linus's poll variation Lyle Coder
2000-11-01 6:31 ` test10-pre7 Peter Samuelson
2000-11-01 7:42 ` test10-pre7 Peter Samuelson
2000-11-03 16:26 ` Vladislav Malyshkin [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-10-31 0:52 test10-pre7 Michael Elizabeth Chastain
2000-10-31 1:05 ` test10-pre7 Christoph Hellwig
2000-10-30 19:32 test10-pre7 Linus Torvalds
2000-10-30 21:37 ` test10-pre7 Keith Owens
2000-10-30 22:01 ` test10-pre7 Jeff Garzik
2000-10-30 22:06 ` test10-pre7 Keith Owens
2000-10-30 22:13 ` test10-pre7 Jeff Garzik
2000-10-30 22:24 ` test10-pre7 Linus Torvalds
2000-10-30 22:41 ` test10-pre7 Keith Owens
2000-10-30 22:51 ` test10-pre7 Linus Torvalds
2000-10-30 23:02 ` test10-pre7 Jeff Garzik
2000-10-30 23:04 ` test10-pre7 Keith Owens
2000-10-30 23:08 ` test10-pre7 Linus Torvalds
2000-10-30 23:03 ` test10-pre7 Keith Owens
2000-10-30 23:15 ` test10-pre7 Linus Torvalds
2000-10-30 23:32 ` test10-pre7 Christoph Hellwig
2000-10-30 23:40 ` test10-pre7 Linus Torvalds
2000-10-30 23:45 ` test10-pre7 Christoph Hellwig
2000-10-30 23:51 ` test10-pre7 Linus Torvalds
2000-10-30 23:57 ` test10-pre7 Christoph Hellwig
2000-10-31 0:47 ` test10-pre7 Linus Torvalds
2000-10-31 1:01 ` test10-pre7 Christoph Hellwig
2000-10-31 2:54 ` test10-pre7 Linus Torvalds
2000-10-31 1:49 ` test10-pre7 Keith Owens
2000-10-31 2:07 ` test10-pre7 Keith Owens
2000-10-31 2:58 ` test10-pre7 Linus Torvalds
2000-10-31 13:55 ` test10-pre7 Peter Samuelson
2000-10-31 17:29 ` test10-pre7 Linus Torvalds
2000-10-31 17:38 ` test10-pre7 H. Peter Anvin
2000-10-31 19:51 ` test10-pre7 Horst von Brand
2000-11-01 2:32 ` test10-pre7 Peter Samuelson
2000-10-31 4:57 ` test10-pre7 Rusty Russell
2000-10-31 6:10 ` test10-pre7 Linus Torvalds
2000-10-30 23:38 ` test10-pre7 Keith Owens
2000-10-30 23:47 ` test10-pre7 Linus Torvalds
2000-10-31 0:03 ` test10-pre7 Keith Owens
2000-10-31 9:37 ` test10-pre7 Russell King
2000-10-31 14:02 ` test10-pre7 Keith Owens
2000-10-31 14:16 ` test10-pre7 Peter Samuelson
2000-10-31 17:31 ` test10-pre7 Linus Torvalds
2000-10-31 19:28 ` test10-pre7 Russell King
2000-10-31 20:59 ` test10-pre7 Linus Torvalds
2000-11-01 3:06 ` test10-pre7 Peter Samuelson
2000-11-01 2:35 ` test10-pre7 Keith Owens
2000-11-01 12:46 ` test10-pre7 Alan Cox
2000-10-31 11:59 ` test10-pre7 Peter Samuelson
2000-10-31 21:01 ` test10-pre7 John Alvord
2000-11-01 3:30 ` test10-pre7 Peter Samuelson
2000-10-31 8:18 ` test10-pre7 Rogier Wolff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A02E71E.745138F4@gromco.com \
--to=mal@gromco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peter@cadcamlab.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox