コード例 #1
0
ファイル: inter.c プロジェクト: Balkhagal/42
void	inter(char *str, char *str2)
{
	int i;

	i= 0;
	while (str[i])
	{
		if (is_in_string(str2, str[i]) && first_time(str, str[i], i))
			write(1, &str[i], 1);
		i++;
	}
}
コード例 #2
0
ファイル: Stream.hpp プロジェクト: gfannes/gubg.io
            static void stream_part_(const Part &part, std::ostream &os)
            {
                S("gnuplot::Stream");
                for (const auto &p: part)
                {
                    const auto ix = p.first;
                    const auto &lines = p.second.lines;
                    stream_data_name_(os, ix);
                    os << " << EOD" << std::endl;
                    for (const auto &line: lines)
                        os << line << std::endl;
                    os << "EOD" << std::endl;
                }

                OnlyOnce first_time;
                for (const auto &p: part)
                {
                    const auto ix = p.first;
                    const auto &info = p.second;
                    const auto nr_cols = info.max_nr_cols;
                    const auto &name = info.name;
                    const auto &col_names = info.col_names;
                    L(C(ix)C(name)C(nr_cols));

                    auto add_plot = [&](unsigned int x, unsigned int y)
                    {
                        if (!first_time())
                            os << std::endl << "pause mouse" << std::endl;
                        os << "plot";
                        /* os << (first_time() ? "plot " : ", "); */
                        stream_data_name_(os, ix);
                        os << " using " << x << ':' << y << " with lines ";
                        os << "t \"";
                        if (!name.empty())
                            os << name << ": ";

                        auto add_name = [&](unsigned int i)
                        {
                            auto it = col_names.find(i);
                            if (it == col_names.end())
                                os << "<unnamed>";
                            else
                                os << it->second;
                        };
                        add_name(x);
                        os << " vs. ";
                        add_name(y);

                        os << "\" ";
                    };
                    if (nr_cols <= 0)
                    {
                    }
                    else if (nr_cols == 1)
                    {
                        //row ix vs. single column
                        add_plot(0, 1);
                    }
                    else
                    {
                        //first column vs. all the others
                        for (auto c = 2; c <= nr_cols; ++c)
                            add_plot(1, c);
                    }
                }
                os << std::endl;
            }