Forum: Ruby Love poem in code for a Grooms Cake

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D03b9bd7c6373e7797bd20f853800b23?d=identicon&s=25 Jen Switalski (engagedtoaprogrammer)
on 2009-03-21 16:33
Hi all,

I am engaged to a programmer.  I, however, know very little about code
other than to always comment!  Was hoping to have a surprise grooms cake
for our wedding with maybe a simple love poem in code written on it.  He
likes writing in Ruby, Perl, etc. (He is a fan of object-oriented and
also of open source).   He also has to write in C or C++ for his job.

Anyway, I was wondering if anyone who sees this post would know of any
"love poems" in a language like one of these. Like love in a forever
loop? Ha, does that even make any sense?

I suppose if I can't find this, I can just get a cake in the shape of
Tux.

I apologize if this is not using the forum appropriately, but don't
really know where else to ask.

Thanks!

P.S. Please no VB. :)
53581739a445ad78250a676dabddf55f?d=identicon&s=25 James Coglan (Guest)
on 2009-03-21 16:46
(Received via mailing list)
2009/3/21 Jen Switalski <jaswitalski@gmail.com>

> loop? Ha, does that even make any sense?
>
> I suppose if I can't find this, I can just get a cake in the shape of
> Tux.
>
> I apologize if this is not using the forum appropriately, but don't
> really know where else to ask.



Well I'm no poet but this is valid Ruby code:

i do
  promise_to_love you until death.parts us
end
59528506e6297141161afcde91d677c9?d=identicon&s=25 Nicolai Reuschling (codeblogger)
on 2009-03-21 17:00
(Received via mailing list)
Hi Jen, what do you think of:

while(true)  I.love(you)
end

Nicolai
D03b9bd7c6373e7797bd20f853800b23?d=identicon&s=25 Jen Switalski (engagedtoaprogrammer)
on 2009-03-21 17:08
Nicolai Reuschling wrote:
> Hi Jen, what do you think of:
>
> while(true)  I.love(you)
> end
>
> Nicolai

Hi Nicolai and everyone.

Thanks for the ideas, but since I don't actually know code, could you
include a short description of what the code says/means?  The two posted
are nice and short, I just honestly don't quite know what they mean.  Or
if they are simply rhyming in code that is not actually executable,
that's okay too.  Thanks!!
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2009-03-21 17:20
(Received via mailing list)
Codeblogger wrote:
> Hi Jen, what do you think of:
>
> while(true)  I.love(you)
> end

Let's make it a one-liner.

I.love(you) while true

Another idea:

I.love(you) until death do |us|
    part
end

Regards,

Dan
0814ff69e309b033508b3c7f363236fd?d=identicon&s=25 Ian Trudel (backorder)
on 2009-03-21 18:18
Jen Switalski wrote:
> Anyway, I was wondering if anyone who sees this post would know of any
> "love poems" in a language like one of these. Like love in a forever
> loop? Ha, does that even make any sense?

Weird! :P


loop do
  p ["Jen", "YourFiancéName"].inject{ |i, you| i + " loves " + you }
end


Replace YourFiancéName accordingly. This small piece of code forever
injects loves between your fiancé and you. ;) As a bonus, it would
output to screen "Jen loves YourFiancéName". A touch of subtlety is
always nice.

Best wishes for your marriage.

Regards,
Ian
Aee77dba395ece0a04c688b05b07cd63?d=identicon&s=25 Daniel Berger (djberg96)
on 2009-03-21 19:13
(Received via mailing list)
On Mar 21, 10:16 am, Daniel Berger <djber...@gmail.com> wrote:
> Another idea:
>
> I.love(you) until death do |us|
>     part
> end

BTW, this isn't "real" code, though it's legal syntax.

Regards,

Dan
59528506e6297141161afcde91d677c9?d=identicon&s=25 Nicolai Reuschling (codeblogger)
on 2009-03-22 01:07
(Received via mailing list)
Hi Jen,
I didn't even notice the rhyme.
Even better I think. :-)

while(true)
>
 I.love(you)
> end
>

It's basically an infinite loop and it's simply two objects ("I" and
"you")
combined by the verb/method "love".
And: Yes, it's actual code.

Glad to be of help!

Nicolai
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2009-03-22 01:19
(Received via mailing list)
There is the shell option:

$ yes "I love you"
I love you
I love you
...

(and so on)

It's not ruby, but most ruby people know some shell commands.
9e2504e0b74e5384af09ce8a660afac4?d=identicon&s=25 Pascal J. Bourguignon (Guest)
on 2009-03-22 03:35
(Received via mailing list)
Codeblogger <codeblogger@gmail.com> writes:

>
> It's basically an infinite loop and it's simply two objects ("I" and "you")
> combined by the verb/method "love".
> And: Yes, it's actual code.

Not really:

    irb(main):208:0> while(true)
                         I.love(you)
                     end
    NameError: uninitialized constant I
        from (irb):210
        from .:0


Rather try:

    class Person
      attr_accessor :name
      def initialize(name)
         @name=name
      end
      def love(otherPerson)
         puts self.name+" loves "+otherPerson.name+"\n"
      end
    end

    I=Person.new("Jen Switalski")
    you=Person.new("a programmer")
    while true
      I.love(you)
    end

    -->
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    Jen Switalski loves a programmer
    ...
852a62a28f1de229dc861ce903b07a60?d=identicon&s=25 Gavin Kistner (phrogz)
on 2009-03-22 04:30
(Received via mailing list)
On Mar 21, 8:33 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
>     I=Person.new("Jen Switalski")
>     you=Person.new("a programmer")
>     while true
>       I.love(you)
>     end

Let's tighten that up a bit, and remove the non-rubyesque camel
casing.

Person = Struct.new( :name ) do
  def love( other )
    puts "#{self.name} loves #{other.name}"
  end
end
I   = Person.new("Jen Switalski")
you = Person.new("Bob")
while true
  I.love(you)
end

Dunno if that'll fit on the cake, but it gets closer.
1bc63d01bd3fcccc36fb030a62039352?d=identicon&s=25 David Masover (Guest)
on 2009-03-23 09:20
(Received via mailing list)
Jen Switalski wrote:
> I apologize if this is not using the forum appropriately, but don't
> really know where else to ask.
>

Well, you might want to ask over on ruby-sonnets...

Seriously, I don't know where else you'd post this.

> P.S. Please no VB. :)
>

Never VB!

You didn't tell us his name, so I'm not sure if this will work... Let's
say it's "Paul":

'Nothing'.between? 'Jan', 'Paul'

Evaluates to true. It means Nothing can come beween Jan and Paul. (Note:
Case-sensitive.) In this case, it's comparing strings -- Nothing is
alphabetically after Jan, and before Paul.

If his name doesn't come after Nothing, it gets trickier. Suppose he's
George:

!'anything'.between? 'Jan', 'George'

(The ! means "not", but "not anything" is less powerful a statement than
"nothing".)

You get the idea. Maybe there are nicknames that will work... Definitely
fits on the cake, at least.
770048af205ed307b8cf35ae2282ee2f?d=identicon&s=25 Michael Malone (Guest)
on 2009-03-23 14:24
(Received via mailing list)
Phrogz wrote:
>>       end
> casing.
> end
>
> Dunno if that'll fit on the cake, but it gets closer.
>
>
Whenever I've seen anything like this done, it's always been done in C.
Though I'm not suggesting we use C, I always thought the #include's
added a little something extra.  So, why not put a couple of require's
at the top?  Such as,
(require is the statement to include library functions/other modules, so
you can re-use functionality)

require 'love'
require 'time'

jen = Person.new("Jen")
fiance = Person.new("Fiance")

us = [jen, fiance]
love = Love.new(jen, fiance)

while(Time.now < Death.parts(us))
    jen.loves(fiance) unless love.conditional?
end


This creates a new 'love' object, taking Jen and Fiance as parameters
(who are set up as 'constants') and loops while the current time is less
than when Death parts the two of you, it says that Jen will love Fiance
unless the love is conditional, which is funny because I put it in a
conditional statement.  It needs editing, but it's something for others
to build on!

Michael



=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
=======================================================================
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Thomas Sawyer (7rans)
on 2009-03-23 18:46
(Received via mailing list)
Probably a little to long...

  death = nil

  def we(r) ; puts "ready to #{x}y!" ; end

  for x in %w{better worse richer poorer sickness health} do
    until death do
      we("part")
    end
  end

But it actually runs.

T.
770048af205ed307b8cf35ae2282ee2f?d=identicon&s=25 Michael Malone (Guest)
on 2009-03-23 18:54
(Received via mailing list)
trans wrote:
>   end
>
> But it actually runs.
>
> T.
>
>
I maintain that it should be 'death do *us* part'
we aren't parting death.
death is parting us.

=======================================================================
This email, including any attachments, is only for the intended
addressee.  It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
 altered or corrupted during transmission.
=======================================================================
D03b9bd7c6373e7797bd20f853800b23?d=identicon&s=25 Jen Switalski (engagedtoaprogrammer)
on 2009-03-24 22:21
All great ideas, thanks everyone!

Jen
This topic is locked and can not be replied to.