I’m trying to use ruby to immitate some C code that broadcasts UDP
packets, but I can only seem to receive packets that are sent to a
specific interface address, not to a broadcast address. Here are the
sender and receiver:
Have you tried binding to the network broadcast address rather than the
global broadcast address ?
e.g. 192.168.1.255
Also, there are anycast address spaces. What address is the UDP packet
broadcast on ? 255.255.255.255
Joel VanderWerf wrote:
···
I’m trying to use ruby to immitate some C code that broadcasts UDP
packets, but I can only seem to receive packets that are sent to a
specific interface address, not to a broadcast address. Here are the
sender and receiver:
It’s the (applicate order) Y-Combinator that’s used to implement
recursion in lambda calculus. It has the property Y(f) = f(Y(f)),
that means that it returns the fixed point of the given function
f.
To define Y is an important step, if you want to prove that the
lambda calculus and turing machine computability are equally
powerful. You can even eliminate the conditional statement,
the numbers (they can be translated to church numerals) and
arithmetic from the expression above and use lambda abstraction
and functional application instead. It’s also possbible
to define pairs and lists that consist of pairs that way.
I hope this explanation helped a bit. If it didn’t: I think
there are a lot of texts who derive this combinator in Scheme
or LISP to be found in the web, that can explain this better than
I can. BTW: Scheme would also make a good LOTY.
···
On Fri, 2004-01-23 at 00:37, Hal Fulton wrote:
Would you explain your .sig? It makes my brain itch.
Would you explain your .sig? It makes my brain itch.
Not only your brain!
It’s the (applicate order) Y-Combinator that’s used to implement
recursion in lambda calculus. It has the property Y(f) = f(Y(f)),
that means that it returns the fixed point of the given function
f.
I was skimming through the threads in the mail list. Imagine my
surprise to find a discussion of the dreaded applicative order Y
combinator in a thread titled “how to broadcast UDP packets”. Cool.
I played around with the Y combinator some years ago, and traces of that
conversation still remain on some mailing list archives. It started
when someone posted a a version of the Y combinator in Perl (shudder).
I responded with a version in Java (double shudder). The java version
didn’t fit so nicely in one line however.
I even wrote out a commented derivation of the Y-combinator. I swear I
understand each individual step of the derivation, but fitting the
entire thing in my head at once is difficult. The derivation in here: http://www.clug.org//ml/archive/programming/1998-11/msg00028.html
I even wrote out a commented derivation of the Y-combinator. I swear I
understand each individual step of the derivation, but fitting the
entire thing in my head at once is difficult. The derivation in here: http://www.clug.org//ml/archive/programming/1998-11/msg00028.html
Thank you very much, Jim.
Exactly what I wanted … now I have some hope of understanding that beast
Ah, you’re using the anonymous inner classes trick. You can even
implement closures (with shared data) that way in Java. It’s very
verbose and also looks pretty ugly though:
public class Closure {
public static void main (String args[]) {
final int a[] = new int[1];
Runnable add = new Runnable() {
public void run() {
a[0] += 1;
System.out.println("I am " + a[0] + ".");
}
};
Runnable sub = new Runnable() {
public void run() {
a[0] -= 1;
System.out.println("I am " + a[0] + ".");
}
};
add.run();
add.run();
sub.run();
}
}
I even wrote out a commented derivation of the Y-combinator. I swear
I understand each individual step of the derivation, but fitting the
entire thing in my head at once is difficult.
The derivation in here: http://www.clug.org//ml/archive/programming/1998-11/msg00028.html
Cool. I’ve done a derivation in Scheme, too, because I did not
understand a more theoretical text on the subject. I the just
translated the solution I found into Ruby, which was pretty easy.
I think it’s important to do this step by step, at least once. Somehow
I felt that I’ve just understood something very important about the
nature of computation when I was done with it. It’s different to
explain, like some zen-like experience I figure.