It is currently Mon Nov 24, 2014 11:03 am



Reply to topic  [ 146 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Thoughts and stuff 
Author Message
Podcast Producer
User avatar

Joined: Mon Jun 30, 2008 10:39 pm
Posts: 7864
Location: Virginia
NNID: DarkWish
3DS Friend Code:
4768-7442-9149
Post Re: Thoughts and stuff
SirVenom wrote:
Yeah, I was thrilled - no apocalypse today! As soon as I talk to my psychologist about my sudden urge to bite someone's skull, all will be well :D

I hope everyone's skull is safe and sound in the new year.

_________________
Image


Tue Jan 01, 2013 5:35 pm
Profile WWW
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
So, I know that some of you besides me work with programming languages. So, I might not just be talking to the air here :p

I am trying to learn Haskell on my own right now. It's a fascinating language, but it requires a huge paradigm shift. Rather than go real deep into what I mean by that at about midnight on the day before an exam, I will just show an example program I wrote. Now, because I wrote it and I am a beginner, it may not be the best solution.

First, let's look at a Caesar cipher method in Java:

Code:
public static String cipher(String orig, int n)
{
   if(n < 0)
   {
      return cipher(orig, 26 - n);
   }
   if(n == 0)
   {
      return orig;
   }

   StringBuffer buffer = new StringBuffer();

   for(int i = 0; i < orig.length(); i++)
   {
      char ch = orig.charAt(i);

      if(Character.isLetter(ch))
      {
         char newCh = (char) (ch + 1);
         if(!Character.isLetter(newCh))
         {
            newCh = Character.isUpperCase(ch) ? 'A' : 'a';
         }
         buffer.append(newCh);
      }
      else buffer.append(ch);
   }

   return cipher(buffer.toString(), n - 1);
}


Now, here's my Caesar cipher function in Haskell:

Code:
import Data.Char

cipher :: [Char] -> Int -> [Char]
cipher [] n = []
cipher s  0 = s
cipher s  n = if n > 0 then cipher [ nextChar c | c <- s ] (n - 1)
              else cipher s (n + 26)

nextChar :: Char -> Char
nextChar c = if isAlpha c
             then if isAlpha next
               then next
               else if isUpper c then 'A' else 'a'
             else c
             where next = (head (tail [c..]))


So elegant, so... different! I would love to get good at this language...

Incidentally, in the last line I created the infinite list [c..]. In Java, the program would run out of space and crash immediately at that point. In Haskell, infinite lists are ubiquitous. It doesn't run out of memory because Haskell never performs more calculations than are needed to perform any task. I asked Haskell for the second character in the infinite list, and it only computes enough of the list to give me that second character. So cool!

_________________
Wise and profound quote.
Image


Thu Jun 20, 2013 1:21 am
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
After a little more playing around, I wrote a sine function:

Code:
sine x = taylorSine x 0

taylorSine x 15 = 0
taylorSine x n  = (((-1)^n)*x^((2 * n) + 1)) / fromIntegral (fac (2*n+1)) + (taylorSine x (n+1))

fac :: Integer -> Integer
fac n = product [1..n]


A call to sine x redirects to a function that computes the first 15 terms of the Taylor series for sine, which is about as close as a computer can get to the right answer. Here is the result:

Code:
*Main> -- This is the stock sine function.
*Main> sin 0
0.0
*Main> sin (pi/4)
0.7071067811865475
*Main> sin (pi/2)
1.0
*Main> sin pi -- This will give a very small number, approximately zero.
1.2246063538223773e-16
*Main> -- Now here is my implementation.
*Main> sine 0
0.0
*Main> sine (pi/4) -- Exactly the same answer as the stock function!
0.7071067811865475
*Main> sine (pi/2)
1.0
*Main> sine pi -- Slightly larger than the stock function answer, but still approximately zero.
4.440892098500626e-16

_________________
Wise and profound quote.
Image


Thu Jun 20, 2013 3:47 pm
Profile
Forum Moderator
User avatar

Joined: Mon Sep 27, 2010 4:41 pm
Posts: 1232
Location: St. Augustine, Florida
3DS Friend Code:
0430-8286-7357
Post Re: Thoughts and stuff
SirVenom wrote:
After a little more playing around, I wrote a sine function:

Code:
sine x = taylorSine x 0

taylorSine x 15 = 0
taylorSine x n  = (((-1)^n)*x^((2 * n) + 1)) / fromIntegral (fac (2*n+1)) + (taylorSine x (n+1))

fac :: Integer -> Integer
fac n = product [1..n]


A call to sine x redirects to a function that computes the first 15 terms of the Taylor series for sine, which is about as close as a computer can get to the right answer. Here is the result:

Code:
*Main> -- This is the stock sine function.
*Main> sin 0
0.0
*Main> sin (pi/4)
0.7071067811865475
*Main> sin (pi/2)
1.0
*Main> sin pi -- This will give a very small number, approximately zero.
1.2246063538223773e-16
*Main> -- Now here is my implementation.
*Main> sine 0
0.0
*Main> sine (pi/4) -- Exactly the same answer as the stock function!
0.7071067811865475
*Main> sine (pi/2)
1.0
*Main> sine pi -- Slightly larger than the stock function answer, but still approximately zero.
4.440892098500626e-16


Yeah....I'm not following this code. I'm an OOP programmer, ever in need of improvement, and this looks totally foreign to me. I looked up Haskell briefly, it seem more difficult to code than .NET, but it also looks impressive. I wish I could be of more help, but I don't think that's a possibility at this time :-).

My final comment to you SV - most impressive.


Thu Jun 20, 2013 3:52 pm
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
Thanks!

If you're interested in Haskell, here is a great place to start. I learned enough to write the functions above in just the first few lectures. The lectures themselves suggest writing the cipher function, and I wrote the sine function as a challenge to myself.

It only makes sense that the code is unreadable. It was to me just a couple days ago. I'll break down the parts of the sine function - I'll use C for reference, since the syntax is familiar.

sine x = taylorSine x 0

This is roughly the same as:

Code:
double sine(double x)
{
   return taylorSine(x, 0);
}


There are only two differences here. I did not specify the return type of the function, or the type of the variable x. I can pass any kind of number into the function (integer, floating, fractional), and I am only guaranteed to get back some sort of number in return.

I could have declared the parameter and return types, but since it is just from a number to a number, I didn't feel the need.

taylorSine x 15 = 0

This is the base case for recursion. So, the start of the C function is...

Code:
double taylorSine(double x, int n)
{
   if(n == 15)
   {
      return 0;
   }
   ...


taylorSine x n = (((-1)^n)*x^((2 * n) + 1)) / fromIntegral (fac (2*n+1)) + (taylorSine x (n+1))

"taylorSine x n" just defines this as any case where n does not equal fifteen. The stuff on the right hand side is this:

Attachment:
taylorseries.gif


Where k = n. Instead of going to k=infinity, of course, I am just going up to k=15.

Note: The "fromIntegral" part just means that it's casting an integer to a floating point number.

Code:
   ... // Actually, this should be before the snippet above, because
   ... // C requires variables to be declared at the beginning.
   ... // Ignore that for now.
   double numerator = pow(-1, n) * pow(x, 2*n+1);
   double denominator = fac(2*n+1);
   return numerator/denominator + taylorSine(x, n+1);
}


The C code looks cleaner here because I broke the equation into several parts. I could have done the same with the Haskell code, but I was just in a hurry to write it and see if it worked. You know how that is :p

I'll put a cleaner version of the Haskell code at the end for a more fair comparison.

fac :: Integer -> Integer

Unlike in the two previous functions, I declared the parameter and return types here. I did this because this version of factorial is only defined for integers, and it only returns integers.

Read it like this: "The type of fac is a function from an Integer to an Integer".

The equivalent C:

Code:
int fac(int n)


fac n = product [1..n]

This is just a standard iterative approach to the factorial function:

Code:
{
   int prod = 1;
   int i;

   for(i = 1; i <= n; i++)
   {
      prod *= n;
   }
   return prod;
}


Now, as promised, here's a cleaner version of that one-line Taylor function thing:

Code:
taylorSine x n  = numerator / denominator + next
                                 where
                                    numerator = ((-1) ^ n) * x^((2 * n) + 1)
                                    denominator = fromIntegral (fac (2*n+1))
                                    next = taylorSine x (n+1)


You do not have the required permissions to view the files attached to this post.

_________________
Wise and profound quote.
Image


Thu Jun 20, 2013 4:32 pm
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
I feel obligated to point out that this implementation eventually diverges to infinity because it only uses a few terms from the series. Close to x=0, however, it is accurate.

_________________
Wise and profound quote.
Image


Thu Jun 20, 2013 9:58 pm
Profile
Forum Moderator
User avatar

Joined: Mon Sep 27, 2010 4:41 pm
Posts: 1232
Location: St. Augustine, Florida
3DS Friend Code:
0430-8286-7357
Post Re: Thoughts and stuff
SirVenom wrote:
The C code looks cleaner here because I broke the equation into several parts. I could have done the same with the Haskell code, but I was just in a hurry to write it and see if it worked. You know how that is :p


Yes, I do know how that is :D. Much of my code could benefit from multiple attempts at optimisation.

Okay SV, honestly, all this is over my head - big time! I am a self-taught programmer from within Visual Studio, so there is much I need to learn. As for the math, not one of my strong suits.

Although this code confuses me, I'm impressed at what you're putting together here. Have you ever considered object oriented programming? Specifically C# or VB.NET? I hear C++ is a great language to learn, but it's much more difficult than C# or VB.


Thu Jun 27, 2013 11:31 am
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
My roots are actually in objected-orientation, since my CS courses were in Java. It's faster and more powerful than some people give it credit for. I know a little C++ (also self-taught from Visual Studio), but I don't know much of it. I'll have to learn more of it eventually :p

I would love to learn C# and VB - they both have great practical applications that Java is a little too heavily engineered for.

_________________
Wise and profound quote.
Image


Sun Jun 30, 2013 4:45 pm
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
That's another semester, another six credits out of the way!

On the nineteenth, I start classes again. I will be taking Calculus III, Physics II, Digital Logic Design, and Japanese I. I'm particularly looking forward to the last two.

_________________
Wise and profound quote.
Image


Fri Jul 26, 2013 10:25 pm
Profile
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
Still alive, and things are going well. I may work as a research and teaching assistant next spring for my Digital Logic Design professor, depending on a few variables.

I've been a bit too strapped for cash to keep up with the gaming world for quite a while now, which is one reason why I haven't been here much. Being behind the curve, I can't really contribute to existing conversations here. Another reason is that I am terrible at multitasking - I have a hard time focusing on maintaining an Internet presence and doing school at the same time. I feel pretty bad about that...

How's life, forum?

_________________
Wise and profound quote.
Image


Sun Nov 10, 2013 6:00 pm
Profile
Podcast Producer
User avatar

Joined: Mon Jun 30, 2008 10:39 pm
Posts: 7864
Location: Virginia
NNID: DarkWish
3DS Friend Code:
4768-7442-9149
Post Re: Thoughts and stuff
SirVenom wrote:
Still alive, and things are going well. I may work as a research and teaching assistant next spring for my Digital Logic Design professor, depending on a few variables.

I've been a bit too strapped for cash to keep up with the gaming world for quite a while now, which is one reason why I haven't been here much. Being behind the curve, I can't really contribute to existing conversations here. Another reason is that I am terrible at multitasking - I have a hard time focusing on maintaining an Internet presence and doing school at the same time. I feel pretty bad about that...

How's life, forum?

YOU LIVE!

Glad to see you around. This forum is practically on life support, unfortunately. I think everyone just got so busy with their lives. I know I did. It's hard to find time to post on all different forums for my different interests, so instead I just focus on Twitter mostly. But I still check in here every day to see if anyone posts anything. I'm just keeping busy with school and work. I posted an update not too long ago in my journal. So that's what's going on with me. But glad to hear from you again SirVenom. I know it's hard to keep up with things when school gets in the way.

_________________
Image


Sun Nov 10, 2013 11:00 pm
Profile WWW
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
Life! Why must it get busier and not easier?

I might need to jump on the Twitter bandwagon someday. What's your handle?

_________________
Wise and profound quote.
Image


Wed Nov 13, 2013 1:20 am
Profile
Podcast Producer
User avatar

Joined: Mon Jun 30, 2008 10:39 pm
Posts: 7864
Location: Virginia
NNID: DarkWish
3DS Friend Code:
4768-7442-9149
Post Re: Thoughts and stuff
SirVenom wrote:
Life! Why must it get busier and not easier?

I might need to jump on the Twitter bandwagon someday. What's your handle?

I'm @hassanahmed120 on Twitter. Most people from NintendoFuse are on there too, so that's where we all talk mostly.

_________________
Image


Wed Nov 13, 2013 10:21 am
Profile WWW
Forum Administrator
User avatar

Joined: Wed May 03, 2006 3:17 pm
Posts: 2628
Location: Eagleland
Post Re: Thoughts and stuff
DarkWish: I am now following you on Twitter.

I wonder what would be best for this forum from now on. The amount of conversation that occurs here now is more appropriate for a shoutbox than a whole forum. Furthermore, I doubt that a forum that is visibly dead (January and February timestamps on the latest posts in most sections) will draw new members, simply because they see a board past its prime.

I have four mutually exclusive ideas:

1. Archive most of the forum, and just have one open forum for chat.
2. Archive everything, hide it from everyone who has not registered before a certain cutoff date, make a completely new forum. Young, fresh, and all that jazz.
3. Lock and archive everything, period. (This is probably overkill, as it only serves to prevent those of us who still like to touch bases from ever communicating through this channel again).
4. Do nothing.

Any thoughts?

Anyway, I would like to write a reflective post soon to talk about my past couple of years. I'll see how quickly I can get to that.

_________________
Wise and profound quote.
Image


Sun Mar 16, 2014 11:40 pm
Profile
Pikmin Chucker
User avatar

Joined: Mon Sep 17, 2007 10:00 pm
Posts: 1593
Location: Boise, Idaho
Post Re: Thoughts and stuff
I feel like since I've joined here it has been struggling to stay afloat. There was time back around when Mario Kart Wii came out that it was pretty active but for the most part there's been about ten of us that regularly post. I wouldn't want to see it shut down mainly because it's just comforting to see that this place is still around even if it doesn't have the user base to sustain it. I should probably follow everyone on Twitter if I want to stay in touch.


Mon Mar 17, 2014 2:34 am
Profile
Forum Administrator
User avatar

Joined: Fri Jul 04, 2008 12:21 am
Posts: 7221
Location: USA
NNID: hattrick
3DS Friend Code:
1590-4688-7305
Post Re: Thoughts and stuff
There are some plans for overall site upgrades that will/should have a positive effect on the forum/community. Details coming when they are available... :-)

_________________
NintendoFuse Editor & Forum Administrator.


Tue Mar 18, 2014 8:24 am
Profile WWW
Octorok
User avatar

Joined: Thu Aug 25, 2011 4:03 pm
Posts: 150
Location: In America
NNID: queenzelda
3DS Friend Code:
2750-1204-9758
Post Re: Thoughts and stuff
Maybe invasion could bring the site back to life? It's a thought anyway. xp But unless the site became something more along the lines of a 'social one' I highly doubt more then 10 ppls will post here. I just post to keep up with old friends who are still here & see how every one is doing. Also I'm most likely the ONLY member here who isn't on twitter either; I'm on deviantart, tumbler, google+, & facebook but I'm not very active on any of them outside of my DA account. ^^;

_________________
Image


Thu Mar 20, 2014 9:40 pm
Profile WWW
Boo
User avatar

Joined: Fri Feb 20, 2009 11:50 pm
Posts: 345
Location: ಠ_ಠ
Post Re: Thoughts and stuff
SirVenom wrote:
DarkWish: I am now following you on Twitter.

I wonder what would be best for this forum from now on. The amount of conversation that occurs here now is more appropriate for a shoutbox than a whole forum. Furthermore, I doubt that a forum that is visibly dead (January and February timestamps on the latest posts in most sections) will draw new members, simply because they see a board past its prime.

I have four mutually exclusive ideas:

1. Archive most of the forum, and just have one open forum for chat.
2. Archive everything, hide it from everyone who has not registered before a certain cutoff date, make a completely new forum. Young, fresh, and all that jazz.
3. Lock and archive everything, period. (This is probably overkill, as it only serves to prevent those of us who still like to touch bases from ever communicating through this channel again).
4. Do nothing.

Any thoughts?

Anyway, I would like to write a reflective post soon to talk about my past couple of years. I'll see how quickly I can get to that.



Why not move to a new forum?

_________________
Image


Fri Apr 25, 2014 4:35 pm
Profile
Podcast Producer
User avatar

Joined: Mon Jun 30, 2008 10:39 pm
Posts: 7864
Location: Virginia
NNID: DarkWish
3DS Friend Code:
4768-7442-9149
Post Re: Thoughts and stuff
WeeGee wrote:
Why not move to a new forum?

We're in the process of revamping the entire site/forum. It's a big project we started working on recently. So while we are kind of dead right now, I think this new concept we're working on will be really unique and interesting.

_________________
Image


Sat Apr 26, 2014 3:26 pm
Profile WWW
Boo
User avatar

Joined: Fri Feb 20, 2009 11:50 pm
Posts: 345
Location: ಠ_ಠ
Post Re: Thoughts and stuff
DarkWish wrote:
WeeGee wrote:
Why not move to a new forum?

We're in the process of revamping the entire site/forum. It's a big project we started working on recently. So while we are kind of dead right now, I think this new concept we're working on will be really unique and interesting.



Jesus let me in on this.

_________________
Image


Sat Apr 26, 2014 8:49 pm
Profile
Octorok
User avatar

Joined: Thu Aug 25, 2011 4:03 pm
Posts: 150
Location: In America
NNID: queenzelda
3DS Friend Code:
2750-1204-9758
Post Re: Thoughts and stuff
Spoiler: show
WeeGee wrote:
DarkWish wrote:
WeeGee wrote:
Why not move to a new forum?

We're in the process of revamping the entire site/forum. It's a big project we started working on recently. So while we are kind of dead right now, I think this new concept we're working on will be really unique and interesting.
Jesus let me in on this.

Nu. :tongue:


Soooooooooooooooooo.. Do j00 like my new signature?? Huh??

"Pikachu!" ;D

_________________
Image


Tue Jul 01, 2014 8:17 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 146 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6

Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by ST Software.