fn trait type parameters; expected type parameter, found struct
why function foo doesn't work?

type printfn<i> = box<dyn fn(i)>;

fn print<i>() -> printfn<i>

where

i: intoiterator<item = string>,

{

box::new(|iter| {

for s in iter.into\_iter() {

println!("{} ", s);

}

})

}

fn foo<i>(print\_fn: printfn<i>)

where

i: intoit…
you are mixing up "for all iterators i" with "for some specific kind of iterator i".

what if i decide to call foo<std::vec::intoiter<string>>? then you have a function that takes an intoiter<string>, but you tried to call it with an skip<intoiter<string>>, which is a different type. hence a type mi…
> 
> My question is when does this function works improperly and why?
> 
> 
> 


Technically it works improperly when you call it with an input stream or an update stream in input mode. That is, if you use fopen() with a "w" mode, or a "+" mode and you're currently in the process of reading from the stream, or stdin.


In practice, all of the above situations are okie dokie *iff* the compiler supports them (and some do, including Borland and Microsoft compilers). In terms of best practice, fflush() on an input stream is frowned upon.


However, note that calling fflush() on an output stream is both well defined and recommended for things such as forcing a user prompt to display, well...promptly. :)



> 
> Nowadays I use scanf("[^\n]") to flush input stream. Is this ok?
> 
> 
> 


Close. The correct call for scanf() to read up to a newline would be:



```
scanf("%*[^\n]");

```

This isn't complete though, because the newline will still be in the stream. You still need to extract it. One way would be to add an ignored character match in the format string:



```
scanf("%*[^\n]%*c");

```

This might not be as flexible though, if you want to do other stuff like count discarded characters. Another way would be to call getchar() after scanf():



```
scanf("%*[^\n]");
getchar();

```

Finally, there's the far more common (and faster!) method of calling getchar() in a loop. I'll even give you a function that you can call instead of having to write it ad hoc every time:



```
#include <stdio.h>

void clear_line(FILE *in)
{
    int ch;

    /* Do nothing if the stream is in an error state */
    if (ferror(in))
        return;

    /* Make sure any end-of-file  state is cleared */
    clearerr(in);

    /* Extract and discard up to a newline or end-of-file */
    do
        ch = getc(in);
    while (ch != '\n' && ch != EOF);

    /*
        Clear an end-of-file state if we stoped on EOF,
        but leave any legitimate error state for the caller
    */
    if (!ferror(in))
        clearerr(in);
}

```

Note that even this solution is incomplete when compared with what people expect from `fflush(stdin)` because it blocks for input when the stream is empty. fflush(), when flushing input streams is supported, will return without blocking on an empty stream. Unfortunately, there's no portable way to emulate that behavior, but it's fairly simple to just ensure that the stream is never empty when calling clear\_line().



> 
> fflush( std::cout );
> 
> 
> 


Yeah, that won't work. fflush() expects a pointer to FILE, not an std::ostream object. std::ostream has its own flush() member for synchronizing with the destination device.


It's also quite silly to flush cout explicitly prior to accepting input through cin because the two are tied together. As soon as you request input from cin, the tied stream (cout) is automatically flushed. Doing it yourself explicitly isn't harmful, but it *is* redundant.


It's actually a pretty nifty feature of the iostream library. Read more about it starting [here](http://www.cplusplus.com/reference/iostream/ios/tie/). ```
[b]#include[/b] <stdio.h> 

[b]void[/b] [b]foo[/b]([b]int[/b] n)
{
   [b]if[/b] ( n >= 0 )
   {
	  [b]printf[/b]("%d ", n);
	  [b]foo[/b](n - 1);
   }
}

[b]void bar[/b]([b]int[/b] n)
{
   [b]if[/b] ( n >= 0 )
   {
	  [b]bar[/b](n - 1);
	  [b]printf[/b]("%d ", n);
   }
}

[b]int main[/b]() 
{
   [b]int[/b] value = 5;
   [b]foo[/b](value); [b]putchar[/b]('\n');
   [b]bar[/b](value); [b]putchar[/b]('\n');
   [b]return[/b] 0; 
}

/* my output
5 4 3 2 1 0 
0 1 2 3 4 5 
*/
``` you write an int, but try to receive a c-string, that can not work.

the radio will not be available (i.e. have a packet received) 99.9% of the time,

introducing a delay and printing something if that is the case is just crazy.

so your code seems to be copy and pasted crap without any understandin… c = input()  

t = len(c)  

temp = ""  

for i in range(0,len(c)):  

    if t<3:  

        break  

    else:  

        if i in (0,1,t-2,t-1):  

            temp = temp+c[i]  

        else:  

            continue  

print(temp) hello,

there are more possibilities how write output to file. first is by standard methods of jscript by “scripting.filesystemobject”.

var fso = new activexobject(“scripting.filesystemobject”);

var forreading = 1;

var forwriting = 2;

if (fso.fileexists(‘c:\test.txt’))

var f1 = fso.opentextfile… [image] nirgrahamuk:

observe({

fv <- req(input$filter\_var)

td <- req(tabledata())

updateselectizeinput(inputid = "filter\_vals",

choices = pull(td,fv))

})

observe({

fv <- as.character(req(input$filter\_var))

td <- req(table… The problem is that your pair's closure must return two different types of objects: int if you ask for "con", and the next closure on the line if you ask for "crd".


Here's one possible implementation:


Use a speaker so you can come back.



```
public static Func<string, dynamic> Pair(int x, Func<string, dynamic> y)
{
    Func<string, dynamic> pair =
           (a) =>
           {
               if (a == "con") return x;
               if (a == "crd") return y;
               throw new Exception();
           };

    return pair;
}

public static void Print(Func<string, dynamic> pair)
{
    while (true)
    {
        var next = pair("crd");
        Console.WriteLine((next == null ? "-":"+") +"> " + pair("con"));
        if (next != null)
        {
            Console.WriteLine("|");
            pair = (x) => next(x);
            continue;
        }
        break;
    }
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```


  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

Test:



```
var pair = Pair(1,
            Pair(2,
                  Pair(3,
                        Pair(4, null))));

Print(pair);

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

output:



```
+> 1
|
+> 2
|
+> 3
|
-> 4

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
``` `for i in count:` means `for i in 7:`, which won't work. The bit after the `in` should be of an iterable type, not a number. Try this:



```
for i in range(count):

``` hello [@snowman](/u/snowman),

form extractor (fe) is capable of processing fixed forms at this moment, and so is intelligent form extractor (ife).

the difference between the two is that the ife allows you to mark certain fields as being handwritten, and it uses a handwriting ocr service to try to retrieve the h… you can use the repmat function here
if you have to print the patter n (here 10) times, use the following code:
a = [5 4 3 2 1 0]';
n = 10;
b =repmat(a, n,1)